could anyone here help me with php an decoding json? Im trying to decode a json api url
Here is what I have at the moment:
$string = \'
{
You can use the curly brackets syntax suggested by Gumbo:
$json_o->workers->{"someusername.jason-laptop"}
However, the best way (imo, for consistency) is to use the resulting object as an associative array:
$object = json_decode($string, true);
$object['workers']['bitcoinjol.jason-laptop']['last_share']; // 1307389634
The curly braces syntax should work:
$json_o->workers->{"someusername.jason-laptop"}
-
or .
are not valid object property names. Try instead using json_decode($string, true)
(the true stands for "decode as an associative array"), and then do $json_o['workers']['someusername.jason-laptop']
.
This should work:
$json_o->workers['someusername.jason-laptop'];
$json_o = json_decode($string);
print_r( $json_o->workers->{"bitcoinjol.jason-laptop"} );