appengine-php
appengine-php copied to clipboard
Json_decode
If I serialize a class with private or protected variables \u0000CLASNAME\u0000 or in case of protected \u0000*\u0000 is prepended to the variable name.
json encoding this string and then decoding it on GAE php55 fails on \u0000.
example code:
class A {
public $pub = 10;
protected $priv = 20;
}
$a = new A();
$serialized = serialize($a);
echo "\nSERIALIZED: ".$serialized;
echo "\nJSON: ". ($json = json_encode($serialized));
echo "\nDECODE".print_r(json_decode($json),1);
echo "\n";
returns (on GAE):
SERIALIZED: O:1:"A":2:{s:3:"pub";i:10;s:7:"*priv";i:20;}
JSON: "O:1:\"A\":2:{s:3:\"pub\";i:10;s:7:\"\u0000*\u0000priv\";i:20;}"
DECODEO:1:"A":2:{s:3:"pub";i:10;s:7:"
while on my development server this works just fine:
SERIALIZED: O:1:"A":2:{s:3:"pub";i:10;s:7:"Apriv";i:20;}
JSON: "O:1:\"A\":2:{s:3:\"pub\";i:10;s:7:\"\u0000A\u0000priv\";i:20;}"
DECODEO:1:"A":2:{s:3:"pub";i:10;s:7:"Apriv";i:20;}
This is also reproducible on GoogleAppEngineLauncher (at least on OS X release: "1.9.20")