Skip to content Skip to sidebar Skip to footer

JSON With \x26 In Values Breaks PHPs Json_decode

https://www.googleapis.com/freebase/v1/search?query=madonna# The JSON result is breaking PHPs json_decode. To be exact, the following string is breaking decoding: 'Sticky \x26amp;

Solution 1:

What's going on is that this is invalid JSON. The response from that url is incorrect--JSON doesn't allow the \xXX two-digit hexadecimal binary escape sequences, only \uXXXX unicode code point escape sequences. Here it should just be &, though--no escape sequence needed.

No idea why google/freebase is outputting invalid JSON.


Solution 2:

Your JSON should look like the following:

"Sticky \\x26amp; SweetTour"

The slash needs to be escaped, because it is the escape char.


Post a Comment for "JSON With \x26 In Values Breaks PHPs Json_decode"