我必须从这样的 json 字符串中解析值:
[{"type":"list","value":["A","B"],"field":"scheda"}]
如何使用 PHP 函数做到这一点json_decode
?
例如我想打印:
field = "scheda"
values = "A,B"
$json = json_decode('[{"type":"list","value":["A","B"],"field":"scheda"}]');
print 'field = "'.$json[0]->field.'"'."\n";
print 'values = "'.implode(",",$json[0]->value).'"'."\n";
如果你不能使用json_decode()
,为什么不尝试一个类?
例如,类似... http://www.phpclasses.org/package/4205-PHP-Serialize-and-unserialize-values-in-JSON-format.html