Handling data in a PHP JSON Object

Handling data in a PHP JSON Object

Trends data from Twitter Search API in JSON. Grabbing the file using: $jsonurl="http://search.twitter.com/trends.json"; $json=file_get_contents($jsonurl,0,null,null); $json_output=json_decode($j…


Deserializing from JSON into PHP, with casting?

Suppose I have a User class with 'name' and 'password' properties, and a 'save' method. When serializing an object of this class to JSON via json_encode, the method is properly skipped and I end up wi…


php - json_decode returns NULL after webservice call

There is a strange behaviour with json_encode and json_decode and I can't find a solution: My php application calls a php web service. The webservice returns json that looks like this: var_dump($foo)…


PHP: is JSON or XML parser faster?

I'm building classes that interface with the Twitter API, and I'm wondering whether PHP's built-in XML or JSON parser is faster? Twitter will send me the same data in either format, so PHP performanc…


How to generate json using php?

I've never used JSON before and I'm trying to utilize the following javascript: http://jqueryselectcombo.googlecode.com/files/jquery.selectCombo1.2.6.js It needs a JSON output in the following format…


Parsing Javascript(not JSON) in PHP

I have a php string containing the serialization of a javascript object:$string='{fu:"bar",baz:["bat"]}'; The actual string is far more complicated, of course, but still well-formed javascript. Th…


Invalid JSON parsing using PHP

I'm pulling a JSON feed that is invalid JSON. It's missing quotes entirely. I've tried a few things, like explode() and str_replace(), to get the string looking a little bit more like valid JSON, but…


PHP-Application config file stored as-ini,php,sql,cached,php class,JSON,php array?

I am trying to decide on the best way to store my applications configuration settings. There are so many options. The majority of applications I have seen have used a simple require and a PHP file tha…



php - json_encode is returning NULL?

For some reason the item "description" returns NULL with the following code:<?php include('db.php'); $result=mysql_query('SELECT*FROM `staff` ORDER BY `id` DESC LIMIT 2') or die(mysql_error());…


json_encode/json_decode-returns stdClass instead of Array in PHP

Observe this little script: $array=array('stuff'=> 'things'); print_r($array);//prints-Array([stuff]=> things)$arrayEncoded=json_encode($array); echo $arrayEncoded."<br/>";//prints-…




json_decode json array string json_encode object from get example data