How can we parse nested JSON
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 06:18 AM
Hi All,
How can we parse nested JSON? I tried it as below, it shows '[object Object],[object Object]'
JSON DATA :
{"returnObj":[{"RequesterUserId":"45333530","RequestCategory":"01","ServiceNowFormNumber":"RITM1234","ScTaskNumber":"SCNum01234","AdminSystemName":"MDM","CustomerNumber":"042721608","KycRm":"072"},{"RequesterUserId":"45333530","RequestCategory":"01","ServiceNowFormNumber":"RITM1234","ScTaskNumber":"SCNum01267","AdminSystemName":"MDM","CustomerNumber":"350802601","KycRm":"610"}]}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 06:30 AM
try this if you want to send the entire nested JSON as a string parameter:
request.setStringParameterNoEscape("returnObj", JSON.stringify(params["returnObj"]));
try this If you want to send the whole payload as the request body
request.setRequestBody(JSON.stringify(params));
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-22-2025 09:06 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-15-2025 12:40 AM
Hi @Ankita9793 ,
I think you want to parse the data from JSON. So I have tried below snippet to parse data.
var jsonData = {
"returnObj": [{
"RequesterUserId": "45333530",
"RequestCategory": "01",
"ServiceNowFormNumber": "RITM1234",
"ScTaskNumber": "SCNum01234",
"AdminSystemName": "MDM",
"CustomerNumber": "042721608",
"KycRm": "072"
}, {
"RequesterUserId": "45333530",
"RequestCategory": "01",
"ServiceNowFormNumber": "RITM1234",
"ScTaskNumber": "SCNum01267",
"AdminSystemName": "MDM",
"CustomerNumber": "350802601",
"KycRm": "610"
}]
}
gs.info(jsonData.returnObj[1].RequesterUserId)so here it will print the
45333530
One thing to consider is that 'returnObj' is the array and each one is array data and we can access those values using "." then property name.
Thanks,
Bhimashankar
----------------------------------------------------------------------------------------
Please mark my answer as helpful/correct if it resolves your query.
----------------------------------------------------------------------------------------
