We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

How to display all hierrarchical data from a given JSON feed so that end users can shape it before saving a filtered report

Answered
Matt Reid asked on March 10, 2022

Hi,
Hope you're all well out there as I think I saw somewhere that you are based out of Ukraine, so hope you've all made it to somewhere away from the front lines!  With regards flexmonster, I'm currently evaluating it's ability to create customised reports on the fly, but the base position prior to any customised reports having been saved will have to be a flat rendition of all hierarchical data.  If I provide the following JSON as an example then how can I get a simple display of all fields in the header row and sub rows for the account data (I've purposely included two records with one and two attached accounts).  Once the raw unfiltered data has been displayed then I want to make use of the flex features in order to shape and aggregate the data, but can you point me at the directive I will need in order to get to that initial flat rendition for the following JSON example please.
Many thanks,
Matt
--
{
"ACCOUNTS": [
{
"customerId": 11651,
"streetAddress": "256 Rio Clara Dr",
"city": "Chicago",
"postalCode": "60610",
"state": "IL",
"country": "USA",
"email": "marv-marola@example.gov",
"phone": "670-018-7377",
"accountCreated": "2014-08-12",
"isHNW": true,
"accounts": [
{
"accountId": 3567361088,
"accountBalance": 9453.563,
"created": "2014-09-21"
},{
"accountId": 3567361090,
"accountBalance": 109453.563,
"created": "2014-10-21"
}
]
},
{
"customerId": 11652,
"streetAddress": "12 Rodeo Dr",
"city": "Hollywood",
"postalCode": "70610",
"state": "CA",
"country": "USA",
"email": "donn-marola@example.gov",
"phone": "670-018-7377",
"accountCreated": "2014-08-12",
"isHNW": false,
"accounts": [
{
"accountId": 4567361088,
"accountBalance": 9453.563,
"created": "2014-09-21"
}
]
}
]
}

Attachments:
fx.json

3 answers

Public
Vera Didenko Vera Didenko Flexmonster March 11, 2022

Hello, Matt,

Thank you for your concern! Our team is safe.
 
Regarding displaying all hierarchical data from a given JSON feed:
Currently, Flexmonster only supports flattened JSON data sources. That means objects inside your data source shouldn't contain arrays or other objects inside them.
To display all the data, we recommend preprocessing it by removing nested arrays, as shown in the example below:

[
{
"customerId": 11651,
"streetAddress": "256 Rio Clara Dr",
"city": "Chicago",
"postalCode": "60610",
"state": "IL",
"country": "USA",
"email": "marv-marola@example.gov",
"phone": "670-018-7377",
"accountCreated": "2014-08-12",
"isHNW": true,
"accountId": 3567361088,
"accountBalance": 9453.563,
"created": "2014-09-21"
},
{
"customerId": 11651,
"streetAddress": "256 Rio Clara Dr",
"city": "Chicago",
"postalCode": "60610",
"state": "IL",
"country": "USA",
"email": "marv-marola@example.gov",
"phone": "670-018-7377",
"accountCreated": "2014-08-12",
"isHNW": true,
"accountId": 3567361090,
"accountBalance": 109453.563,
"created": "2014-10-21"
},
{
"customerId": 11652,
...
},
...
]

Here is a JSFiddle for demonstration: https://jsfiddle.net/flexmonster/p4a6ocwj/.
In the example, we also specified the desired fields' data types via mapping (see guide for more details).
 
Please let us know if this approach works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Vera

Public
Matt Reid March 11, 2022

Thanks Vera that's great.  We had a meeting this morning and came to the conclusion that we would probably have to denormalise our data anyway, so many thanks for confirming this as the recommended approach.  I have subsequently tried this with denormalised data and it does give the results we were after, so many thanks for your help.  Currently integrating it with charting, but I'll raise my next query on that side of things in a separate ticket, so that the questions and answers are better correlated rather than hidden down in this chain of responses.  Glad to hear you're all OK!

Public
Vera Didenko Vera Didenko Flexmonster March 11, 2022

Hello, Matt,
 
Thank you for your reply.
 
We are happy to hear that you found our response helpful.
 
As for creating a separate ticket for the chart integration question, our team would appreciate it. Such an approach will help others to find solutions to related cases.

We will be looking forward to hearing from you.
 
Kind regards,
Vera

Please login or Register to Submit Answer