jquery - php: converting an array of objects to pure array -


following array received @ server side :

[{"id":"2","foo":"bar","children":[{"id":"4","foo":"baz","children":[{"id":"6"}]},{"id":"5"}]},{"id":"7"},{"id":"3"}] 


there way convert nested array this?

[   ['id' => 2, 'foo' => 'bar', 'children' =>[                                              'id'=> 4, 'foo' => 'baz' .... 

p.s: find out without using function have desired code format on server side. maybe because of sending data post request (using ajax) convert data array serialize , send , on server side have nice array same i'm looking for.im not sure ralated php or laravel or jquery !?

array ( [0] => array     (         [id] => 2         [children] => array             (                 [0] => array                     (                         [id] => 4                         [children] => array                             (                                 [0] => array                                     (                                         [id] => 6                                     )                              )                      )                  [1] => array                     (                         [id] => 5                     )              )      )  [1] => array     (         [id] => 7     )  [2] => array     (         [id] => 3     )  ) 

to array in php, yes. use json_decode().

to "nested array this" in json, no. not how arrays in json supposed look. see specification @ json.org, easy understand.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -