How can I access nested json records?

Hello all,

I'm trying to build a report using a json data feed - while I can access the first level of data within the feed I am unable to access any second level data. I'm not entirely sure I am using the correct terminolgy so I have provided a screen capture of the data source record tree (see below). What I'm trying to do is auto discover the field under record.add_outlet.record tree node, when I hit next the field list is empty.

This is a data source/set for a table within the report - ultimately I would like access the sub levels from a sub report.

 I have tried to find a solution using various forums and can only find reference to solutions involving net.sf.jasperreports.engine.data.JsonDataSource and subdataSource which I'm strugging to understand yet alone implement.

I would appreciate any assiistance that could be provided. Should I continue to try and understand the JsonDataSource subDataSource approach or is there alternative solution?

I am using Jaspersoft Studio 6.0.3.

Kind Regards

David

DaveKay's picture
Joined: Jul 31 2013 - 9:28pm
Last seen: 7 years 1 month ago

Can you post an example JSON? This is a good service for doing so https://gist.github.com/

ernestoo - 7 years 10 months ago

Thanks for taking a look ernestoo, the gist link is below - not used it before - just added an issue and pasted in the json, hope that's okay.

https://github.com/DaveKay/SampleJSON/issues/1

Regards

David

DaveKay - 7 years 10 months ago

1 Answer:

So not 100% sure what you're looking to do but here is a little video explnation that might help you get going http://screencast.com/t/4uzHZ0tJojjh

ernestoo's picture
17658
Joined: Nov 29 2010 - 11:59am
Last seen: 5 years 3 months ago

Thank you for that ernesto :-)

I have just taken a look at the video and will try to apply what you have shown me. There are a few things there that I was not aware of.

What I would like to do in the end is have a report that shows the top level inspection data and loops through the sub level records (add_an_outlet, add_an_inlet, add_defect records for each inspection in either a table or a sub report using the Parameter and the PARENT_ID and ID relationship.

I really do appreciate you taking the time to create a step by step video for me...amazing!

I'd better get to it - will let you know how I go.

DaveKay - 7 years 10 months ago

Okay ernesto - I was able to replicate what you showed me. I'm still however struggling to get either a table or a sub form populated with data.

What I want to be able to is insert a table ( or a sub report ) that will report the 'add_an_outlet' records for each of the top level records. The add_an_outlet records are associated with the parent record via the PARENT_ID field.

record.ID --> record.add_an_outlet.record.PARENT_RECORD_ID ( 1 to many ).

I think what I need to do is similar to the sample described here;
http://jasperreports.sourceforge.net/sample.reference/jsondatasource/

and the json data source sample in the Jasper Report Library.
http://sourceforge.net/projects/jasperreports/files/jasperreports/Jasper...

Hopefully you get what I mean and can still assist.

Kind Regards
David

DaveKay - 7 years 10 months ago

Hi there ... essentially you are trying to do something similar to this article, it is quite similar for XML & JSON so should be helpful http://community.jaspersoft.com/wiki/accessing-nested-repeated-fields-yo... - best of luck!

ernestoo - 7 years 10 months ago
Feedback