/** * stringify to a string * * @param Result $result The result will be serialized * @return string The serialized result */ public static function stringify($result) { $output = array(); if (!is_null($result->error)) { $output['error'] = $result->error; } if (is_null($result->responses)) { return json_encode($output); } $output['responses'] = array(); foreach ($result->responses as $id => $response) { $output['responses'][$id] = Response::stringify($response); } return json_encode($output); }