Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Json_decode #2

@samek

Description

@samek

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions