inanutshellus Posted September 20, 2012 Share Posted September 20, 2012 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`. Link to comment Share on other sites More sharing options...
mdahlman Posted September 21, 2012 Share Posted September 21, 2012 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? Link to comment Share on other sites More sharing options...
inanutshellus Posted September 26, 2012 Author Share Posted September 26, 2012 Pretty spot-on blog post. JRMapCollectionDataSource seems to be exactly what I want, though I can't seem to even *declare* a Field of type java.util.List in a JSON report. Any idea what that's about? Link to comment Share on other sites More sharing options...
Solution inanutshellus Posted October 10, 2012 Author Solution Share Posted October 10, 2012 The answer is, in fact, that JSON datasources do not support lists without this patch:http://community.jaspersoft.com/comment/reply/705457 Link to comment Share on other sites More sharing options...
narcism Posted November 20, 2012 Share Posted November 20, 2012 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. Link to comment Share on other sites More sharing options...
inanutshellus Posted January 14, 2013 Author Share Posted January 14, 2013 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? Link to comment Share on other sites More sharing options...
mike2tango Posted August 25, 2014 Share Posted August 25, 2014 you do not need to. Just pass a sublist to a subreport. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now