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

Parse a JSON field for a value

Answered
Brian asked on September 14, 2022

Hi,
We have some non-flat JSON data in one of our fields. Is there a way in the client to parse the JSON and only display the desired value?
Thanks,
Brian

5 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster September 15, 2022

Hello, Brian!
 
Thank you for your question. 
 
Please note that Flexmonster supports only flat JSON data.
Therefore, we kindly recommend flattening your JSON data source before passing it to Flexmonster.
 
You can find more details about supported JSON formats in our docs: https://www.flexmonster.com/doc/json-data-source/#supported-formats.
 
We hope it helps.
Feel free to contact us if any further questions arise.
 
Regards,
Solomiia

Public
Brian September 15, 2022

Hi Solomiia,
So there is no way to use a customizeCell function to accomplish this? I just did a tiny bit of research on that, but have not attempted it yet.
Thanks,
Brian

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster September 16, 2022

Hello, Brian!
 
Thank you for your swift reply.
 
Kindly note that customizeCell() API call is used to change the appearance of data on the grid, e.g., add custom links or change the formatting. 
The customizeCell() function is called after the report is loaded and the data is retrieved from the data source. 
You can read more about customizeCell() usage in our docs: https://www.flexmonster.com/doc/customizing-grid/.
 
Therefore, we kindly suggest modifying data to flat format before passing it to Flexmonster. The idea lies in the following:
1. Receive the JSON data from the server.
2. Flatten the JSON any way you want
3. Use the data property to set a modified JSON object as a data source:

report: {
   dataSource: {
    data: flattenData
   }
}

The flattenData can be either a JSON object itself or the function flattenData(), which returns a JSON object.
 
Hope you will find our answer helpful.
Feel free to contact us if any further questions arise.
 
Regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster September 27, 2022

Hello, Brian!

Hope you are doing well.

Our team is wondering if you had some time to look through our previous answer.
Could you please let us know if it was helpful?

Looking forward to hearing from you.

Regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster October 4, 2022

Hello, Brian!

Hope you are having a great week.

Just checking in to ask if the suggested approach of flattening JSON was helpful.

Please let us know if you have any further questions.

Regards,
Solomiia

Please login or Register to Submit Answer