JSON Parser: Why is it ignoring the blank spaces?

andy_dufresne
Tera Expert

Try this code in the background script:

var message = "{'short_description':'PROBLEM:  agent on asdfasdf is unreachable for 5 minutes','contact_type':'alert','impact':'1 - High','urgency':'1 - High','service_offering':'asdfasdf'}";

var parser = new JSONParser();
var parsed = parser.parse(message);

gs.print(parsed.short_description);

 

How can I make it show the whole show_description value?  I tried to escape with'\' no luck.  Also anything I can do in the parser code to stop this?

 

Thanks and have a great day!!

1 ACCEPTED SOLUTION

shawna
Tera Guru

Json requires double quote and I usually use JSON.parse for parsing Json objects.

 

Try this:

var message = '{"short_description":"PROBLEM: agent on asdfasdf is unreachable for 5 minutes","contact_type":"alert","impact":"1 - High"}';

var parsed = JSON.parse(message);

gs.print(parsed.short_description);

View solution in original post

2 REPLIES 2

shawna
Tera Guru

Json requires double quote and I usually use JSON.parse for parsing Json objects.

 

Try this:

var message = '{"short_description":"PROBLEM: agent on asdfasdf is unreachable for 5 minutes","contact_type":"alert","impact":"1 - High"}';

var parsed = JSON.parse(message);

gs.print(parsed.short_description);

THANK YOU!!!