0

我必须从这样的 json 字符串中解析值:

[{"type":"list","value":["A","B"],"field":"scheda"}] 

如何使用 PHP 函数做到这一点json_decode

例如我想打印:

field = "scheda"
values = "A,B"
4

2 回答 2

4
$json = json_decode('[{"type":"list","value":["A","B"],"field":"scheda"}]');
print 'field = "'.$json[0]->field.'"'."\n";
print 'values = "'.implode(",",$json[0]->value).'"'."\n";
于 2013-10-04T16:17:48.723 回答
0

如果你不能使用json_decode(),为什么不尝试一个类?

例如,类似... http://www.phpclasses.org/package/4205-PHP-Serialize-and-unserialize-values-in-JSON-format.html

于 2013-10-04T16:17:25.500 回答