Reading multiple json values with php

Posted by jason on Stack Overflow See other posts from Stack Overflow or by jason
Published on 2010-03-15T09:11:47Z Indexed on 2010/03/15 9:19 UTC
Read the original article Hit count: 240

Filed under:
|

I am trying to read certain values from a json string in php, I am able to do a simple json string with only one value such as

$json = '{"value":"somevalue"}';

Using this:

<?php 
      $json = '{"value":"somevalue"}';
      $obj = json_decode(json_encode($json));
      print $obj->{'value'};
?>

But when i try an get a value from the following json string it throws an error...

$json = '{"field": "title","rule": {"required": "true","minlength": "4","maxlength": "150" }}';

I validated the json on JSONlint but not sure how to access the values within this with php.

  • Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about JSON