1.加了JSON_FORCE_OBJECT参数的json_encode($foo,JSON_FORCE_OBJECT)得到的是
{
"bar1": {},
"bar2": {}
}
2.(object)
$foo = array(
"bar1" => (object)array(), // Should be encoded as an object
"bar2" => array() // Should be encoded as an array
);
echo json_encode($foo);
// {"bar1":{}, "bar2":[]}
网友评论