I have to parse values from a json string like this:
[{"type":"list","value":["A","B"],"field":"scheda"}]
How can I do that using PHP function json_decode?
For example I want print:
field = "scheda"
values = "A,B"
i alarmed alien
9,5403 gold badges30 silver badges40 bronze badges
asked Oct 4, 2013 at 16:13
epi82
4972 gold badges10 silver badges22 bronze badges
2 Answers 2
$json = json_decode('[{"type":"list","value":["A","B"],"field":"scheda"}]');
print 'field = "'.$json[0]->field.'"'."\n";
print 'values = "'.implode(",",$json[0]->value).'"'."\n";
Sign up to request clarification or add additional context in comments.
Comments
If you can't use json_decode(), why not try a class?
For instance, something like... http://www.phpclasses.org/package/4205-PHP-Serialize-and-unserialize-values-in-JSON-format.html
Comments
lang-php