0

Forgive my terminology im a newbie in in web dev.

To visualize my question, see below.

This is how RESTLER displays json:

[
 {
   "id": 1,
   "name": "Daniel Craig",
   "email": "dc@gmail.com"
 },
 {
   "id": 2,
   "name": "Tom Cruise",
   "email": "tc@gmail.com"
 }
]

This is how i would want RESTLER to display json results:

{"actors":[
 {
   "id": 1,
   "name": "Daniel Craig",
   "email": "dc@gmail.com"
 },
 {
   "id": 2,
   "name": "Tom Cruise",
   "email": "tc@gmail.com"
 }
]}
Arul Kumaran
  • 983
  • 7
  • 23
Reyboy
  • 9

1 Answers1

0

Just wrap your result with another array. if we assume that $result returns the first result above, do the following

$result = array(
 array(
   "id" => 1,
   "name" => "Daniel Craig",
   "email" => "dc@gmail.com"
 ),
 array(
   "id" => 2,
   "name" => "Tom Cruise",
   "email" => "tc@gmail.com"
 )
);

return array('actors'=>$result);
Arul Kumaran
  • 983
  • 7
  • 23