we've been storing json_encoded structures on disk in several places because it's a lot easier to parse than xml - but OMG do they get mangled - stored as single quoted strings when escaped as if double quoted. We need to use my new function json_decode_plus() wherever we need to parse one of these babies to make sure we get it right. Maybe we should've just used serialize().
This commit is contained in:
@@ -1717,3 +1717,11 @@ function jindent($json) {
|
||||
}
|
||||
|
||||
|
||||
function json_decode_plus($s) {
|
||||
|
||||
$x = json_decode($s,true);
|
||||
if(! $x)
|
||||
$x = json_decode(str_replace(array('\\"','\\\\'),array('"','\\'),$s),true);
|
||||
return $x;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user