php - Double Quote and backslashes JSON reply -
using api provided supplier i've got json reply formatted :
{"d":"{\"idproduct\":0,\"status\":0,\"errors\":[\"b_message_invalid_required_fields\"]}"} that causing in issue when trying deserialize jms (php) because content of d not considered object string.
i have tried creating json php array , json_encode() , works great deserialize method :
{"d":{"idproduct":123456,"status":1,"errors":["b_message_invalid_required_fields"]}} is possible remove useless backslashes , quotes side? seems supplier can not change format.
it looks api returns a json string encoded json object. meaning, first need decode "outer" object, json-decode $obj['d'], because it's json string.
json_decode(json_decode($json)->d) obviously should fix api not return double-encoded json.
Comments
Post a Comment