Forum Discussion

mccoleman's avatar
mccoleman
New Contributor
2 years ago

JSON output nested in array

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

  • 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).

    Hope this helps!

     

     

     

     

  • SpiroTaleski's avatar
    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.