I would like to convert an object 'Resonse' that contains an array with objects to a JSON string.
Example of the data structure:
$response = new model_ObjectReponse();
$error1 = new model_Message('error', 'test error 1');
$error2 = new model_Message('error', 'test error 2');
$error3 = new model_Message('error', 'test error 3');
$response->add($error1);
$response->add($error2);
$response->add($error3);
$output = json_encode($response);
print $output;
The message objects have the private properties type and message with getters and setters.
So does anybody know how to convert this to a json string? Btw, I have the same question for converting it to XML.
Thanks for the help.