How to pass tags in a new line JSON Format

SKum
Kilo Sage

Hello, I need to Pass tags <Remove>R</Remove> in a new line like below, I tried using \n  but i am not able to add in a new line how do i pass ?

 

"Content": [
{
"ID": "123",
"Name": "Name1"

<Remove>R</Remove>
}

{
"ID": "1234",
"Name": "Name2"
}

]

 

 

Here is the sample code I tried 

var incomingData = '{"tag":"<Remove>R</Remove>"}';
var parsedData = JSON.parse(incomingData);
gs.info(parsedData.tag);

var request = {
Content: [
{
"ID": "123",
"Name": "Name1"
},
{
"ID": "1234",
"Name": "Name2" +
'\n'+parsedData.tag
}
]
};
var jsonString = JSON.stringify(request,null,4);
gs.print(jsonString)
7 REPLIES 7

SKum
Kilo Sage

@Ankur Bawiskar  Any thoughts?

Ankur Bawiskar
Tera Patron

@SKum 

what's your requirement here?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

SKum
Kilo Sage

@Ankur Bawiskar Thanks for responding!

 

I need to send tag <Remove>R</Remove> in a JSON format in POST operation like below, I am able to send in the same line using the sample code above like "Name": "Name1 <Remove>R</Remove>" but not in the next line, how do i pass it in next line? 

 

 

"Content": [
{
"ID": "123",
"Name": "Name1"

<Remove>R</Remove>
}

{
"ID": "1234",
"Name": "Name2"
}

]

 

Thanks

@SKum 

I don't think you can add new line there

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader