/** * Test serialize with recursion * * @return void */ public function testSerializeRecursion() { $c1 = new stdClass(); $c1->c2 = new stdClass(); $c1->c2->c3 = new stdClass(); $c1->c2->c3->c1 = $c1; $c1->something = 'ok'; $c1->c2->c3->ok = true; $expected = '{"@type":"stdClass","c2":{"@type":"stdClass","c3":{"@type":"stdClass","c1":{"@type":"@0"},"ok":true}},"something":"ok"}'; $this->assertSame($expected, $this->serializer->serialize($c1)); $c1 = new stdClass(); $c1->mirror = $c1; $expected = '{"@type":"stdClass","mirror":{"@type":"@0"}}'; $this->assertSame($expected, $this->serializer->serialize($c1)); }
/** * @param ResponseInterface $response * @param JsonResult $jsonResult * @return ResponseInterface */ private function modifyResponseForJsonResult(ResponseInterface $response, JsonResult $jsonResult) { $json = $this->jsonSerializer->serialize($jsonResult->getData()); $stream = \GuzzleHttp\Psr7\stream_for($json); return $response->withHeader('Content-Type', 'application/json')->withBody($stream); }
protected function __store($id, &$value, $ttl) { $this->engine->save($id, $this->serializer->serialize($value), $ttl); }
public function updateBeneficiaryEvaluation($evaluation) { $data = -1; try { // -- Find data $serializer = new \Zumba\Util\JsonSerializer(); $evaluationStr = $serializer->serialize($evaluation, false); $request = $this->client->post('evaluations', array(), $evaluationStr); $response = $request->send()->json(); if (StatusConstants::OK == $response['status']) { if (!array_key_exists('data', $response)) { return $data; } $data = $response['data']; } else { throw new \Exception($response['message'], StatusConstants::toCode($response['status'])); } } catch (\Exception $e) { throw new \Exception('Erreur lors de l\'appel au P4S : updateBeneficiaryEvaluation()', StatusConstants::toCode(StatusConstants::UNKNOWN_ERROR), $e); } return $data; }
/** * {@inheritDoc} */ public function serialize(DomainMessage $domainMessage) { return $this->serializer->serialize($domainMessage, 'json'); }