Page 1 of 1

JSON in "pretty" format?

Posted: 09 Jul 2018 17:07
by lord_EarlGray
Hi,

Is there any way to log JSON http response in pretty format? I have occasionally problems with parsing JSON and I can't find reason when it is logged in one line.

Re: JSON in "pretty" format?

Posted: 09 Jul 2018 17:51
by Desmanto
Automagic already has function to convert back-thru from JSON to Map object and vice versa. The JSON converted will be indented (pretty format). So you can nested this to the response.

Code: Select all

pretty = toJSON(fromJSON(response));
fromJSON() will convert the response to map/list object. toJSON() will convert it back to JSON, but in indented version (pretty format).

But if you only need to check the value only (just to help with reading only), you can simply put condition debug dialog after the response. Then find the response > Show value in text editor > 3 dot menu > Format JSON. This only change the view only, but doesn't change the real response value as the one above.

Re: JSON in "pretty" format?

Posted: 09 Jul 2018 18:05
by lord_EarlGray
That works perfect for me! Thanks!