我有这个json
{
"name": "Default",
"url": "{controller}\/{action}",
"params":
[{
"controller": "Home",
"action": "index"
}]
}
我想重建原始对象,但json_decode()
给了我这个
object(stdClass)#1 (3) {
["name"]=>
string(7) "Default"
["url"]=>
string(21) "{controller}/{action}"
["params"]=>
array(1) {
[0]=>
object(stdClass)#2 (2) {
["controller"]=>
string(4) "Home"
["action"]=>
string(5) "index"
}
}
}
鉴于我不知道它会在那里,因为params依赖于url,我只知道我的对象将具有name
,url
和params
属性。
是否有动态方法将params
设置为数组?
object(stdClass)#1 (3) {
["name"]=>
string(7) "Default"
["url"]=>
string(21) "{controller}/{action}"
["params"]=>
array(2) {
["controller"]=>
string(4) "Home"
["action"]=>
string(5) "index"
}
}