- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎09-10-2020 05:55 AM
Hi,
I have a JSON stored in a column of a table . I want to read it in script task of Virtual Agent Topic. I am doing the below but unable to get the keys or value, can anyone help with this please?
Solved! Go to Solution.
- Labels:
 - 
						
							
		
			Agent  Workspace
 
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎09-10-2020 06:12 AM
Hi,
Try this alternative way
you need to use decode in order to convert that json string as object
var obj = new global.JSON().decode(reqTemp.toString());
for ( var key in obj)
{
     gs.info(" key is : " + key + " and value for key is " + obj[key]);
}
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
 
‎09-10-2020 06:08 AM
Hi,
please try this
var obj = JSON.parse(reqTemp.toString());
for(var key in obj){
}
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
 
‎09-10-2020 06:12 AM
Hi,
Try this alternative way
you need to use decode in order to convert that json string as object
var obj = new global.JSON().decode(reqTemp.toString());
for ( var key in obj)
{
     gs.info(" key is : " + key + " and value for key is " + obj[key]);
}
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
 
‎09-10-2020 07:00 AM
Thank you, this worked.
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎09-10-2020 09:32 AM
You are welcome
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
