我有一个webservice返回这个JSON文件:
{"success":true,"msg":"[{\"inCarico\":\"1\",\"a\":\"2007-01-12 00:00:00\",\"b\":\"\",\"cd\":\"\",\"ef\":\"\",\"IdL\":\"0\",\"IdM\":\"0\"}]"}现在我使用这段代码来解码json并获取msg内容,但是我想解码每个语音(carico,a,b,IdL.)以“味精”的声音。
$url = 'http://......';
$obj = json_decode(file_get_contents($url), true);
echo $obj['msg'];我该怎么做?
发布于 2016-06-08 07:03:36
你得用json解码两次。
$json = '{"success":true,"msg":"[{\\"inCarico\\":\\"1\\",\\"a\\":\\"2007-01-12 00:00:00\\",\\"b\\":\\"\\",\\"cd\\":\\"\\",\\"ef\\":\\"\\",\\"IdL\\":\\"0\\",\\"IdM\\":\\"0\\"}]"}';
$result = json_decode ($json, true);
$arr = json_decode ($result['msg'], true);
print_r($arr);结果:
Array
(
[0] => Array
(
[inCarico] => 1
[a] => 2007-01-12 00:00:00
[b] =>
[cd] =>
[ef] =>
[IdL] => 0
[IdM] => 0
)
)请告诉我我现在能为你做什么吗?
https://stackoverflow.com/questions/37695358
复制相似问题