json-decode

What's wrong with my JSON?

Anybody out there notice anything wrong with this JSON? It validates at JSONLint.com, but neither Chrome nor Firefox's native JSON parse functions will properly parse it. Any ideas? { "result": "{\"players\":[{\"name\":\"User 522\",\"turn\":true,\"score\":0},{\"name\":\"User 925\",\"turn\":false,\"score\":5}],\"enableContr...

Problem with Json Date format when calling cross-domain proxy

I am using a proxy service to allow my client side javascript to talk to a service on another domain The proxy is a simple ashx file with simply gets the request and forwards it onto the service on the other domain : using (var sr = new System.IO.StreamReader(context.Request.InputStream)) { requestData = sr....

How can I put double quotes inside a string within an ajax JSON response from php?

I receive a JSON response in an Ajax request from the server. This way it works: { "a" : "1", "b" : "hello 'kitty'" } But I did not succeed in putting double quotes around kitty. When I convert " to \x22 in the Ajax response, it is still interpreted as " by JavaScript and I cannot parse the JSON. Should I also escape the \ and unesc...

Decode json string returned from Flickr API using PHP, curl

Im trying to decode a json string returned from flickr within my PHP code. Im using CURL but it keeps returning a string even when I wrap json_decode() around the json sring variable. Any ideas? $api_key = '####'; $photoset_id = '###'; $query = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key='.$...

Receive JSON payload with ZEND framework and / or PHP

I'm receiving a JSON payload from a webservice at my site's internal webpage at /asset/setjob. The following is the JSON payload being posted to /asset/setjob: [{"job": {"source_filename": "beer-drinking-pig.mpg", "current_step": "waiting_for_file", "encoding_profile_id": "nil", "resolution": "nil", ...

PHP Object conversion question

I am converting from JSON to object and from object to array. It does not what I expected, can you explain to me? $json = '{"0" : "a"}'; $obj = json_decode($json); $a = (array) $obj; print_r($a); echo("a0:".$a["0"]."<br>"); $b = array("0" => "b"); print_r($b); echo("b0:".$b["0"]."<br>"); The output here is: Array ( [0] => a ) a0: Ar...

JSON Search and remove in php?

Hello! I have a session variable $_SESSION["animals"] containing a deep json object with values: $_SESSION["animals"]='{ "0":{"kind":"mammal","name":"Pussy the Cat","weight":"12kg","age":"5"}, "1":{"kind":"mammal","name":"Roxy the Dog","weight":"25kg","age":"8"}, "2":{"kind":"fish","name":"Piranha the Fish","weight":"1kg","age":"1"}, "...

How to remove $ from associative array using Json_decode in php?

I am trying to use the youtube API to pulldown some videos for my site. Currently am running this code here: //Youtube Videos Pull Down $youtubeURL = "http://gdata.youtube.com/feeds/api/videos?alt=json&amp;q=cats+cradle+chapel+hill&amp;orderby=published&amp;max-results=10&amp;v=2"; $youtubeSearch = file_get_contents($youtubeURL, true);...

Decoding and caching json every 60 minutes

Hi, How do I do this on a php webpage? I want to get and decode a json string and display the results as html on my page, however, I don't want it hotlinking back to the source. If I could write the decoded string to a txt file say weather.txt on the server and keep the html formatting and do it so that the page won't fetch the json...

python simpleJSONDecoder and complex JSON issue

In a unit test case that I am running, I get a KeyError exception on the 4th json object in the json text below because the piece of code responsible for decoding is looking for an object that isn't there, but should be. I went through the sub-objects and found that it was the "cpuid" object that causes the problem. When I remove it ...

problem in getting JSON data through server?

I am using Tropo Web API, to get result from a chat application, i redirected my JSON response to my server side PHP file(http://myhost.in/vj/app3.php?tropo-engine=json), the JSON response is coming correctly but i am not able to fetch data from that using PHP, the JSON response is as follows.. { "result": { "actions": ...

php json decode - get a value

I'm trying to extract a specific value from json content . Here it is link with the json code http://www.ebayclassifieds.com/m/AreaSearch?jsoncallback=json&amp;lat=41.1131514&amp;lng=-74.0437521 As you may see the the code displayed is json({items:[{url:"http://fairfield.ebayclassifieds.com/",name:"Fairfield"},{url:"http://newyork.ebayc...

How to send array datatype to server?

I am using PHP as server side coding, and i want a set of values to be send to the server(in array format). how can i send that, and retrieve that array value at backend? ...

Need help modifying curl php image get script please

I need to modify this simple script, have searched the web for hours but getting nowhere with it. What I need to do is firstly fetch the url to be used from either a text file on my site or from a decoded json output - such as "$FullPicURL = "http://somesite.com" . $data[2];" or "file_put_contents($image, file_get_contents("http://somes...

Using single 'smart quote' in my JSON data is breaking PHP script

Hi folks, I've got a PHP script that is reading in some JSON data provided by a client. The JSON data provided had a single 'smart quote' in it. Example: { "title" : "Lorem Ipsum’s Dolar" } In my script I'm using a small function to get the json data: public function getJson($url) { $filePath = $url; $fh = fopen...

Problem using json in Golang (Go)

I am using json to store data on disk between program calls, the program runs fine for some time, but after that it displays error in json decoding, "invalid character '1' after top-level value ". Can anyone suggest some solution to this problem ? ...

Python and JSON: using object_hook to do class hinting for multiple different classes

Using the json module in python 2.6, I'm experiencing some unexpected behavior when passing a function to object_hook. I'm attempting to turn a json object into a class defined in my code. This class requires that instances of a different class as arguments. Something like this: class OuterClass: def __init__(self, arg, *InnerClass_...

alternative to json_decode before PHP 5.2

Is there a simple alternative to using json_decode function in php versions prior to 5.2? I am feeling lazy at this time of night and can't be bothered to update php yet. Cheers. ...

Parse simple JSON

Hi, I have a trouble to parse this piece of JSON { "00408C88A2E6": { "id": "00408C88A2E6", "name": "pippo"}, "00408C91188B": { "id": "00408C91188B", "name": "pluto" }, "00408C944B99": { "id": "00408C944B99", "name": "minni" }, "00408C944BA0": { "id": "00408C944BA0", "nam...

PHP: JSON decoding problem

<?php $handle = fopen("https://graph.facebook.com/[email protected]&amp;type=user&amp;access_token=2227472222|2.mLWDqcUsekDYK_FQQXYnHw__.3600.1279803900-100001310000000|YxS1eGhjx2rpNYzzzzzzzLrfb5hMc.", "rb"); $json = stream_get_contents($handle); fclose($handle); echo $json; $obj = json_decode($json); print $obj->{'id'}; ?...