Need a special offer?Find out if your project fits.
+

how to validate a Flexmonster Report JSON file

Closed
Eric Malalel asked on December 20, 2019

I would like to know if you provide, online if possible, a JSON schema file to validate that a JSON string is a well formatted Flexmonster report saved as a JSON file.
Currently, I just check that the JSON is valid, but it would be nice to check further that the content is what I expect.

3 answers

Public
Vera Didenko Vera Didenko Flexmonster December 23, 2019

Hello, Eric,
 
Thank you for writing to us.

Currently, we don't have a report object online validator, but the structure of the report object can be checked by referring to our documentation: https://www.flexmonster.com/api/report-object/
We would like to explain that report objects which are generated by Flexmonster are valid by default.
 
Could you please provide more details on what you would like to achieve?
This will help us to understand the situation better and find the best solution for your case.
 
Looking forward to your reply.
 
Best regards,
Vera

Public
Eric Malalel December 24, 2019

Hello Vera,
I provide a solution to my customers which is based on WordPress.
I use the WordPress Media Library to store FlexMonster reports (JSON files) defined by "power users', which can then be used by all users to get ready to use pivots and graphs.
These users just have to select a report, it is very much like the "open remote report" of the FlexMonster toolbar.
As the WordPress Media Library can contain all kinds of JSON files, I would like to check that the selected JSON file is a valid FlexMonster report, hence my request for a JSON validator.
 

Public
Vera Didenko Vera Didenko Flexmonster December 24, 2019

Hello, Eric,
 
Thank you for providing additional details. 
 
A possible differentiator could be to check if the JSON object contains the dataSource field.
If yes, then the chances are that it is a Flexmonster report object.
Here is a JSFiddle for illustration: https://jsfiddle.net/flexmonster/L4028xgy/
 
Also, if you would like to restrict the chosen report object to having only Flexmonster report object's properties, you can construct a sample JSON object constant containing the main report object's fields.
Then you could check if the chosen JSON object's fields are one of your constant's.
Here is an example illustrating the general idea: https://jsfiddle.net/flexmonster/1roefwhj/
 
Hope this helps.
 
Please let us know if any additional questions arise.
 
Best regards,
Vera

This question is now closed