Assuming this is the actual value shown, consider:
twice_json = '"{\\"orderId\\":\\"123\\"}"' // (ingore the extra slashes) json = JSON.parse(twice_json) // => '{"orderId":"123"}' obj = JSON.parse(json) // => {orderId: "123"} obj.orderId // => "123"
Note that applying JSON.stringify to a json value (which is a string, since JSON text is text) will result in a twice_json value. Next, consider the relationship between obj (a JavaScript object) and json (a JSON string).
That is, if the result indicated in the message is the output from JSON.stringify(res) , then res is already JSON (which is text / a string), and not a JavaScript object, so do not call stringify for the JSON value already! Rather, use obj = JSON.parse(res); obj.orderId obj = JSON.parse(res); obj.orderId , according to the above demos / conversions.
source share