Retrieve value from Response.getBody() in JSON

manish123
Giga Guru

Hi All,

In REST integration, we are getting Response.getBody() with lots of fields and values respective to it. However, i would like to get some specific value from that Response.Could anyone please let me know how to get that? I tried with decode and Parse but still in log its displaying undefined.

1 ACCEPTED SOLUTION

Result does not appear to be an array. I'm reaching this as:



gs.log('Number=' + jsonObject.result.number);


View solution in original post

42 REPLIES 42

Chuck Tomasi
Tera Patron

Can you share the code and a sample of the JSON object you are getting? Thanks.


Hi Chuck,



Thanks for quick reply.


Below is the line of code:-


var response = r.execute();


//var responseBody = response.getBody();


var jsonBody =   response.getBody();


var jsonObject = JSON.parse(jsonBody);


gs.log('REST data parsed: ' + jsonObject.number );



On log, I am getting:-


REST data parsed: undefined


Can you include a bit of that JSON string you get from the respose.getBody() call?


Here its Chuck:-



Reached here :{"result":{"u_update_set_name":"","skills":"initial","upon_approval":"proceed","location":"","expected_start":"","u_technical_service":"","close_notes":"closed successfully","service_offering":"","u_total_hours_worked":"2","u_project":"abc","additional_assignee_list":"test","impact":"3","urgency":"3",