JSON with \x26 in values breaks PHPs json_decode
browser, google-api, javascript, json, php
Solution
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.
Problem
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; Sweet Tour". Browsers however seem to be able to understand it: http://jsfiddle.net/nggX2/ & http://jsfiddle.net/QUVFt/ http://jsonlint.com/ claims it's invalid JSON. On PHP's side I've tried: http://codepad.viper-7.com/suUbQD and http://codepad.viper-7.com/QjqCH7 Any thoughts on what's going on?