Devraj Mukherjee Thu Aug 30 19:54:52 -0400 2012

Subject: Serializing (to_json) relationships or a Group of objects

Hi all,

Is it possible to run to_json on a collection and or children if I define relationships? So on a result of ::all

At the moment I am looping through each object in the array running to_json and stitching the string together to construct the output JSON.

E.g:

$json_string = "[";
foreach($user->grids as $grid) {
$json_string .= $grid->to_json().",";
}
$json_string = substr($json_string, 0, -1);
$json_string .= "]";
return $json_string;

Any pointers will be appreciated.