[Developers] json_decode issue

Christopher R. Maden crism at metaweb.com
Tue Sep 9 15:08:47 UTC 2008


Vivek Puri wrote:
> I am fetching data from freebase and running it through my php script. 
> The php script performs json_decode <http://us.php.net/json_decode> of 
> the json output from freebase. On almost all the data i fetch, it works 
> just fine, except for the following API call:
> 
> '{"query":{ "query" : [ { "album" : [ { "/common/topic/image" : [ {} ], 
> "length" : null, "id" : null, "name" : null, "sort" : "name", 
> "release_date" : null, "track" : [] } ], "name~=" : "Nusrat Fateh Ali 
> Khan", "type" : "/music/artist" } ] }}'
> 
> In the above case when i do the json_decode, i get output as null. Any 
> ideas what might be causing that? My php version is 5.2.3

The query seems to run just fine; the only possible problem I can think 
of is that PHP’s decoder doesn’t handle UTF-8 text.  One of those albums 
has a French title and French track titles with accents; if PHP doesn’t 
handle the UTF-8 encoding correctly, it might trip over those.  Does the 
decoder have a problem with the results of this query?

{
   "id" : "/guid/9202a8c04000641f8000000002fbf759",
   "name" : null,
   "track" : [],
   "type" : "/music/album"
}

If not, then it may just be the number of albums here.  Are you sure 
you’re actually getting a result from that query, and not a time-out? 
If you are, are you sure that PHP’s decoder doesn’t have some kind of 
size limitation on the input?

~Chris
-- 
Christopher R. Maden
Data Architect
Freebase.com: <URL: http://www.freebase.com/ >
Metaweb Technologes, Inc. <URL: http://www.metaweb.com/ >


More information about the Developers mailing list