- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 05:20 AM
Hello experts,
I have created a HTML page & consumes custom application REST API. I need to parse the response which has JSON array & require to display the record id in the HTML page. I have tried to use it as JSON object but it did not help. I have attached the sample response in the thread.
Valuable feedback is required.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 05:04 AM
Thread closed. Issue has been fixed by the below code
var resp=this.response;
respo = JSON.parse(resp);
//console.log(respo.result.length);
for (var i=0; i < respo.result.length; i++)
{
console.log(respo.result[i].number);
alert(respo.result[i].number);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 05:34 AM
HI,
Which value you want from this result?
Also can you give me text for this reponse. From image i can't take it for coding.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 05:50 AM
FYI
{
"result": [
{
"parent": "",
"made_sla": "true",
"watch_list": "",
"u_when_needed": "2017-05-18 21:52:02",
"upon_reject": "cancel",
"sys_updated_on": "2017-01-30 22:51:35",
"u_what_needed": "legal1",
"approval_history": "",
"number": "NI002004",
"sys_updated_by": "admin",
"opened_by": {
"link": "https://dev22387.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441",
"value": "6816f79cc0a8016401c5a33be04be441"
},
"user_input": "",
"sys_created_on": "2017-01-30 22:51:35",
"sys_domain": {
"link": "https://dev22387.service-now.com/api/now/table/sys_user_group/global",
"value": "global"
},
"state": "3",
"sys_created_by": "admin",
"knowledge": "false",
"order": "",
"closed_at": "2017-01-30 22:51:35",
"cmdb_ci": "",
"delivery_plan": "",
"impact": "3",
"u_requested_for": {
"link": "https://dev22387.service-now.com/api/now/table/sys_user/46d44a23a9fe19810012d100cca80666",
"value": "46d44a23a9fe19810012d100cca80666"
},
"active": "false",
"work_notes_list": "",
"business_service": "",
"priority": "4",
"sys_domain_path": "/",
"time_worked": "",
"expected_start": "",
"opened_at": "2017-01-30 22:50:27",
"business_duration": "",
"group_list": "",
"work_end": "",
"approval_set": "",
"work_notes": "",
"short_description": "When does the ESPP window close?",
"correlation_display": "",
"delivery_task": "",
"work_start": "",
"assignment_group": "",
"new_field_1": "",
"additional_assignee_list": "",
"description": "",
"calendar_duration": "",
"close_notes": "",
"sys_class_name": "x_58872_needit_needit",
"closed_by": {
"link": "https://dev22387.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441",
"value": "6816f79cc0a8016401c5a33be04be441"
},
"follow_up": "",
"sys_id": "e1bc2a030fe03200cd674f8ce1050ea4",
"contact_type": "",
"urgency": "3",
"company": "",
"reassignment_count": "0",
"activity_due": "",
"assigned_to": "",
"u_request_type": "legal",
"comments": "",
"approval": "not requested",
"sla_due": "",
"comments_and_work_notes": "",
"due_date": "",
"sys_mod_count": "0",
"sys_tags": "",
"escalation": "0",
"upon_approval": "proceed",
"correlation_id": "",
"location": ""
}
]
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 05:57 AM
HI,
You can use this:
var parser = JSON.parse(responseBody);
var result = parser.result;
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 06:01 AM
See this as well:
var jparser = new JSONParser();
var jparserValue = jparser.parse(data);
jparserValue['Devices'].length;
This is an example:
Thanks,
Ashutosh