RE: [PHP-DEV] JSON inclusion in core
| From: | Jared Williams | Date: | Sat, 21 Jan 2006 13:30:44 +0000 |
| Subject: | RE: [PHP-DEV] JSON inclusion in core | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-21621@lists.php.net to get a copy of this message | ||
> AFAIK an object in JSON is just an associative array in PHP,
> so I don't see the point here in implementing that in
> anything else than an associative array on the PHP side.
>
The json extension currently creates stdClass objects.
$config = '{"windowA":
{
"left": 10,
"right": 10,
"height": 100,
"width": 100
},
"windowB":
{
"left": 120,
"right": 120,
"height": 120,
"width": 120
}
}';
$a = json_decode($config);
var_dump($a);
Outputs:
object(stdClass)#1 (2) {
["windowA"]=>
object(stdClass)#2 (4) {
["left"]=>
int(10)
["right"]=>
int(10)
["height"]=>
int(100)
["width"]=>
int(100)
}
["windowB"]=>
object(stdClass)#3 (4) {
["left"]=>
int(120)
["right"]=>
int(120)
["height"]=>
int(120)
["width"]=>
int(120)
}
}
Also it'd been nice if the requirement to have name/label in double quotes was removed, (I
havent read a JSON spec, so it maybe
correct) but javascript doesn't require it.
Jared