Take the following JSON line (generated by some ExtJS code, but that doesn't matter):
[{"action":"Setting","method":"toggle","data":["welcome-home"],"type":"rpc","tid":2},{"action":"ContentExtFeFillout","method":"todo","data":[true,0,8,false],"type":"rpc","tid":3}]
sent to the server as a request POSTand retrieved via $GLOBALS['HTTP_RAW_POST_DATA'].
Launch
json_decode($GLOBALS['HTTP_RAW_POST_DATA']);
on our development machine ( 5.2.10-2ubuntu6.4with the Suhosin patch 0.9.7) gives the correct conclusion print_r():
Array
(
[0] => stdClass Object
(
[action] => Setting
[method] => toggle
[data] => Array
(
[0] => welcome-home
)
[type] => rpc
[tid] => 2
)
[1] => stdClass Object
(
[action] => ContentExtFeFillout
[method] => todo
[data] => Array
(
[0] => 1
[1] => 0
[2] => 8
[3] =>
)
[type] => rpc
[tid] => 3
)
)
Running the same code on the client machine ( 5.2.5using Suhosin Patch 0.9.6.2and Zend Optimizer, SUSE Linux by the way) gives the following print_r()output:
Array
(
[0] => stdClass Object
(
[action] => Setting
[method] => toggle
[data] => Array
(
[0] => welcome-home
)
[type] => rpc
)
[1] => 2
[2] => stdClass Object
(
[action] => ContentExtFeFillout
[method] => todo
[data] => Array
(
[0] => 1
[1] => 0
[2] => 8
[3] =>
)
[type] => rpc
)
[3] => 3
)
Pay attention to the missing property , which, obviously, was moved to the main array as an eigenvalue - this, of course, violates all of the following codes. tid
PHP Windows 5.2.5, , json_decode(), .
- json_decode() , ?
...
!