prettify/format json

1
Hi All, From our Mendix application we are doing Export to JSON. the generated file contains the details in one line. For example: export is done with details as  {"key":"value","key":"value","key":{"key":"value"},"key":{"key":"value","key":"value"}}   Question : How can we prettify/format json in mendix before the export , so that we have below result in the json file.   {     "key": "value",     "key": "value",     "key": {         "key": "value"     },     "key": {         "key": "value",         "key": "value"     } }      
asked
1 answers
0

Hi,

 

you have three options:

  1. Send your json to an online service for JSON beautify. But probably you don’t want to send your data to some online service, which leaves you with option 2.
  2. Create a java action for pretty-print/beautify of your JSON. There are some java libraries that you can leverage. But be careful not to import too many dependencies, some of them are heave.
    Some examples:
    Gson: https://github.com/google/gson
    JSON-Java: https://github.com/stleary/JSON-java
  3. Option 2 of course is also possible as a JavaScript action
answered