- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2025 08:38 AM
i am getting the rest api response like below
Response Body: {"id":"dsajnddna","id2":"orn","id3":"orndawdw"}
now i want get the id2 value from this body, i am unable to get the id2 value. please help mee
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2025 08:55 AM
If your response body is a JSON string:
var responseBody = '{"id":"dsajnddna","id2":"orn","id3":"orndawdw"}';
var obj = JSON.parse(responseBody);
var id2 = obj.id2; // "orn"
If your response body is already a JSON object:
var id2 = responseBody.id2;
If you need to guard against missing fields:
var id2 = (obj && obj.id2) ? obj.id2 : null;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2025 08:55 AM
If your response body is a JSON string:
var responseBody = '{"id":"dsajnddna","id2":"orn","id3":"orndawdw"}';
var obj = JSON.parse(responseBody);
var id2 = obj.id2; // "orn"
If your response body is already a JSON object:
var id2 = responseBody.id2;
If you need to guard against missing fields:
var id2 = (obj && obj.id2) ? obj.id2 : null;