我有一个有效的json格式{"active":"false","period":"23-05-2017 to 25-05-2017","percentage":null,"value":null,"status":"inc","fixed_price":null}
但是,当我尝试解码时,它会返回错误
我错过了什么吗?Response内容必须是实现__toString()," object"的字符串或对象。给出。
答案 0 :(得分:2)
将你的json函数包装在'
中。结果使用$json = '{"active":"false","period":"23-05-2017 to 25-05-2017","percentage":null,"value":null,"status":"inc","fixed_price":null}'
。
注意开放和关闭。然后你可以调用json_decode($ json)
这是工匠修补匠的完整结果:
>>> $json = '{"active":"false","period":"23-05-2017 to 25-05-2017","percentage":null,"value":null,"status":"inc","fixed_price":null}'
=> "{"active":"false","period":"23-05-2017 to 25-05-2017","percentage":null,"value":null,"status":"inc","fixed_price":null}"
>>> json_decode($json);
=> {#869
+"active": "false",
+"period": "23-05-2017 to 25-05-2017",
+"percentage": null,
+"value": null,
+"status": "inc",
+"fixed_price": null,
}