cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove/replace square brackets and extra curly braces in a json file using expressions in mapper

abinayad
New Contributor

Hi Team,

I want to remove the square brackets and extra curly braces in the given json file to convert the json file to expression file. My input file is as below.

[
{
“Test”: {
“xyx”: “x”,
“abc”: “a”,
“pqr”: “p”
}
},
{
“Test1”: {
“opq”: “o”,
“stu”: “s”,
}
}
]

But I want to convert the above file as below.

{
“Test”: {
“xyx”: “x”,
“abc”: “a”,
“pqr”: “p”
},

"Test1": {
  "opq": "o",
  "stu": "s"
}

}

Any suggestions like how I can achieve this.

2 REPLIES 2

nseaman
New Contributor

I’d also be interested in the solution to this issue.

In my pipeline I use a File writer, and the file payload is not contained in square brackets, but when I work with the file in Snaplogic I see that a set of square brackets has been added, which contains the entire payload/file content. This set of brackets disrupts the downstream workflow when attempting to Rest Post.

edit: this post resolved my issue - adding the content-type to the HTTP Header in my Rest Post snap
How to change default array document structure? - #2 by ddangler

darshthakkar
Valued Contributor