I am having an issue dealing with the notation used in a JSON file I am trying parse. Some of the nodes have . (periods) in the names which escapes object-notation
($json
You can use braces around the name to access the property:
<?php
$o = json_decode('{"docs": [{"rssFeed.type": "news", "rssFeed.url": "http://www.example.com/", "score": 1.0 }]}');
var_dump($o->docs[0]->{'rssFeed.url'});
?>
@eWolf: you are still right, php is almost like javascript as its C like nature.
$object = json_decode('{"docs": [{"rssFeed.type": "news",
"rssFeed.url": "http://www.example.com/",
"score": 1.0 }]}', TRUE);
Note: the 2nd argument to json_decode()
, TRUE
. It forces the function to return an associative array.
Now $object['rssFeed.type']
can be used.