我必须解析json字符串中的值,如下所示:
[{"type":"list","value":["A","B"],"field":"scheda"}]
我怎样才能使用PHP函数json_decode
?
例如我想要打印:
field = "scheda"
values = "A,B"
答案 0 :(得分:4)
$json = json_decode('[{"type":"list","value":["A","B"],"field":"scheda"}]');
print 'field = "'.$json[0]->field.'"'."\n";
print 'values = "'.implode(",",$json[0]->value).'"'."\n";
答案 1 :(得分:0)
如果您不能使用json_decode()
,为什么不尝试上课?
例如,...... http://www.phpclasses.org/package/4205-PHP-Serialize-and-unserialize-values-in-JSON-format.html