- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 03:11 AM
Am getting response as below line,
"{\"Table\":[[\"Yes\"],null]}"
And it contains Yes, if Yes is present in response i need to do something, how to parse or split the response to identify Yes or No present in it?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 03:39 AM
Hi Swathi,
Here is the code. I have executed in background and value is coming as Yes
you can also test
var str = '{"Table":[["Yes"],null]}';
var parsed = new JSONParser();
var parsedData = parsed.parse(str);
gs.print('Value is:'+parsedData.Table[0]);
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 02:26 PM
Hi
I need to extract "pi.sri"
please help me out I am getting undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2017 01:00 AM
Hi Pranav,
Firstly check whether the json is correctly formatted.
use this website JSON Editor Online - view, edit and format JSON online
and put this in left hand side, it gives error it means it is not correct json.
from what I see is that this is a valid json from the string you shared
{
"scope":["INA"],
"client_id":"INA",
"pi.sri":"CZRPnW66-JE6mPkZMfOM",
"ssr":"resr",
"snwd":"restuer",
"Email":"D.Idaest1et",
"exp":1501162800
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2017 02:44 AM
Hi ankur
Actually I am getting this from the request body so I am putting it in an unescape variable and in logs it is currently showing but when I try to insert in table there is some problem

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2017 02:44 AM
json extraction please see this thread
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 03:41 AM
Hi Swathi,
Below is the sample piece to cover escaped to json object.
var k=unescape("{\"Table\":[[\"Yes\"],null]}");
var json=new JSON().decode(k);
You would want to add an if condition to see if the value is Yes
var k=unescape("{\"Table\":[[\"Yes\"],null]}");
var json=new JSON().decode(k);
if(json.Table[0]=='Yes')
{
// write your code
}