cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
0 Kudos

Beautify or Pretty Print Associative Arrays or JSON Objects

What inspired this wish list request? Needing to copy arrays / json elements into a separate text editor to make visially appealing to quickly skim keys/values/structure

 

What is the improvement you would like to see? I would like to see a better 'reformat' button or a specific item for reformatting Associative Arrays and JSON objects.

In other editors I have seen this called 'format json', 'pretty print', or 'beautify' ... but in the end, it's merely formatting the object for the human eye.

 

Why is this idea important? Associative Arrays and JSON object can become complex quickly and displaying them in block text is difficult to look at and see what is going on. Moreover, looping through these objects may take more time and / or doesn't really help understand what we need to look at -- especially if we just want a quick gut check looking at something.

 

As an example: Here's an associative array as it appears in the log:

["fieldName" => "product",
"filterDetails" => {["all" => false, "field" => ["error" => false,
"multivalue" => false,
"name" => "product"], "only" => false, "polarity" => "INCLUDE", "values" =>
{"CatOne"}]}, "from" => 1, "timeFacet" => "EOW", "to" => 1]


Pasting it into a new JSL window to 'look at it more cleanly', highlighting, and hitting the reformat button produces this:

["fieldName" => "product",
"filterDetails" => {["all" => false, "field" => ["error" => false,
"multivalue" => false,
"name" => "product"], "only" => false, "polarity" => "INCLUDE", "values" => {"XXX"}]}, "from" => 1,
"timeFacet" => "EOW", "to" => 1]


But what should happen, and does in other editors (once I convert the AA to a JSON object) is something more like this (manually formatted with underscores for spaces here as a pasted format lost all indentations in preview):

[

____"fieldName" => "product",

____"filterDetails" => {

________[

____________"all" => false,

____________"field" => [

________________"error" => false,

________________"multivalue" => false,

________________"name" => "product"

____________],

____________"only" => false,

____________"polarity" =>

____________"INCLUDE",

____________"values" => {"XXX"}

________]

____},

____"from" => 1,

____"timeFacet" => "EOW",

____"to" => 1

]

1 Comment
Status changed to: Acknowledged

Thank you for your request! We've taken a look and will update you if there are any developments.