Jasper Reports comes with a sample report using a JSON datasource, and the "jsonCustomerReport" shows exactly what I want it to, but it does so by requerying the entire datasource for each subreport, like so:
<subreportParameter name="net.sf.jasperreports.json.source">
<subreportParameterExpression><![CDATA["data/northwind.json"]]></subreportParameterExpression>
</subreportParameter>
Let's say I wanted the Customer Report that looks like this:
Maria Anders of Beverly Hills
Order #100
Order #101
Ana Trujillo of New York City
Order #102
Order #103
Order #104
But using this data as a string passed in as an InputStream:
{"SomeJsonObject": {
"Customers": [ {
"ContactName": "Maria Anders",
"CustomerID": "ALFKI",
"Address": {
"Street":"123 Sesame St",
"City":"Beverly Hills"
},
"Orders": [ {
"OrderID": 100 // Other stuff snipped
}, {
"OrderID": 101
}
]
}, {
"ContactName": "Ana Trujillo",
"CustomerID": "ANATR",
"Address": {
"Street":"456 Sesame St",
"City":"New York City"
},
"Orders": [ {
"OrderID": 102
}, {
"OrderID": 103
}, {
"OrderID": 104
}
]}
]}
}
How would I access the Orders array?
I wanted to use a SubDataSet and a List component, but I don't know what to put for the `dataSourceExpression`.
2 Answers:
Posted on October 10, 2012 at 6:32am
The answer is, in fact, that JSON datasources do not support lists without this patch:
http://community.jaspersoft.com/comment/reply/705457
Posted on September 21, 2012 at 12:26am
This article was written with MongoDB in mind. But it should apply equally well to your JSON data source. Does that solve it for you?

Of course you could tie a JSON data source to a list and pull data out of it. But for this case, though, more work needs to be done.
Please visit this issue: http://community.jaspersoft.com/jasperreports-library/issues/2500-0
Basically it's the same request that you pointed to, only that it has been turned into an issue now.
I notice the ticket has been stuck on "Feedback Requested" for a while. From whom are you expecting feedback? Other Jasper SE staff? The Author? Arbitrary netizens such as myself?