Assuming that is the actual value shown then 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 how applying JSON.stringify to the json
value (which is a string, as JSON is text) would result in the twice_json
value. Further consider the relation between obj
(a JavaScript object) and json
(the JSON string).
That is, if the result shown in the post is the output from JSON.stringify(res)
then res is already JSON (which is text / a string) and not a JavaScript object – so don’t call stringify on an already-JSON value! Rather, use obj = JSON.parse(res); obj.orderId
, as per the above demonstrations/transformations.