how to read below json data in php?
i have "$json = json_decode($data,true); and i tryied "$json->{'screenShareCode'};" but is is giving me an error? :(
array(5) { ["screenShareCode"]=> string(9) "887874819" ["appletHtml"]=> string(668) "" ["presenterParams"]=> string(396) "aUsEdyygd6Yi5SqaJss0=" ["viewerUrl"]=> string(65) "http://api.screenleap.com/v2/viewer/814222219?accountid=myid" ["origin"]=> string(3) "API" }
Your output is regular array not JSON, so you access it as regular PHP array:
$x = $array['screenShareCode']
You are looking for json_encode (http://de2.php.net/json_encode)
The output you are showing is not json. It seems to be a print_r'ed array.
What you posted is an array, not an object. Because you passed json_decode
a second parameter of true
, it responded with an associative array instead of an object.
To access a property of an associative array, you can do something like $json['screenShareCode']
.