cancel
Showing results for 
Search instead for 
Did you mean: 

JSON output nested in array

mccoleman
New Contributor

Good evening,

I have an array of elements that I'd like to output as JSON: 

[{...},{...},{...}]

In order to nest this array under a JSON property, I utilize the "Group by N" snap, which results in my data looking like this: 

{

   "randomKey": [{...},{...},{...}]
}


This is passed into a JSON formatter. Upon looking at the output JSON however, it appears that what I'm actually getting is this: 

[{

   "randomKey": [{...},{...},{...}]
}]

How can I configure the JSON formatter to not nest my response in an array? Why is it happening? 

 

2 REPLIES 2

SpiroTaleski
Valued Contributor

@mccoleman 

Also, another way of nesting the array under a JSON property is by using a Mapper Snap. 

About the formatting of the JSON, check the "Format each document" checkbox.

SpiroTaleski_0-1707470885822.png

koryknick
Employee
Employee

@mccoleman - or you leave your JSON documents at the root level and use the JSON Formatter with default configuration (I use Pretty-print just to make it easier to read).

koryknick_0-1707480314627.png

koryknick_1-1707480430123.png

koryknick_2-1707480465760.png

Hope this helps!