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