Jump to content
We've recently updated our Privacy Statement, available here ×

Access Nested json records from more than 1 objects using same data source.


nazaf

Recommended Posts

I have been trying to fetch data from two objects. I have json data where there are 5 objects, out of which 1 has values as an array. I am successfully able to fetch data from the object which has value has an array and use the fields in my report. But,i was trying to get a field from the 1st object as well which on using comes as null. I am posting the image.

jsonqstn.png.0883f1b37f61d3c7179c63244c9809af.png

 

These 3 fields i am using in my report. i want the field 'name' from 1st object to be used with the report but i am not being able to do so.

jsonqstn1.png.e382325ed74948b0e9626b5620f721de.png

 

Can someone please help me out here?

 

Regards,

Nazaf

Link to comment
Share on other sites

  • 2 months later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • 5 months later...

It is possible, but with some effort if you are willing to use the current implementation of JSON data source.

An easier solution is to wait for the 6.3.1 release of the JasperReports Library and the JasperSoft Studio where we have createad a new JSON query language meant to solve issues like this. A new sample with extensive documentation will be available in the Data Source / Query Executer section of the sample reference page(http://jasperreports.sourceforge.net/sample.reference.html) once the JasperReports Library 6.3.1 release is out.

If you are tight to the current JSON implementation, these are the main steps to achieve what you want:

  1. use an empty query as the queryString
  2. create a field with the "city.name" description
  3. create a subDataset(for e.g. name it ListSubDataset) with the "temp.day", "temp.min", "temp.max" for the descriptions of the fields
  4. create a list that uses the ListSubDataset and pass it a dataSource expression like this one:

<datasetRun subDataset="ListSubDataset">

<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}.subDataSource("list")]]></dataSourceExpression>

</datasetRun>

A working example with subDatasets and lists can be found here:

http://community.jaspersoft.com/jasperreports-library/issues/2500-0

or here

http://community.jaspersoft.com//questions/825620/how-deal-json-list-jsondatasource

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...