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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -