I have this json
{
"name": "Default",
"url": "{controller}\/{action}",
"params":
[{
"controller": "Home",
"action": "index"
}]
}
I wanted to reconstruct the original object, but json_decode()
gave me this
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"
}
}
}
Given that I don't know what it will be in there, because params depend on the url, I only know that my object will have name
, url
and params
properties. Is there a dynamic way to set params
as an array?
object(stdClass)#1 (3) {
["name"]=>
string(7) "Default"
["url"]=>
string(21) "{controller}/{action}"
["params"]=>
array(2) {
["controller"]=>
string(4) "Home"
["action"]=>
string(5) "index"
}
}