|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
namespace Symfony\Component\Serializer\Encoder; |
|
|
4 |
|
|
|
5 |
use Symfony\Component\Serializer\SerializerInterface; |
|
|
6 |
|
|
|
7 |
/* |
|
|
8 |
* This file is part of the Symfony framework. |
|
|
9 |
* |
|
|
10 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
11 |
* |
|
|
12 |
* This source file is subject to the MIT license that is bundled |
|
|
13 |
* with this source code in the file LICENSE. |
|
|
14 |
*/ |
|
|
15 |
|
|
|
16 |
/** |
|
|
17 |
* Encodes JSON data |
|
|
18 |
* |
|
|
19 |
* @author Jordi Boggiano <j.boggiano@seld.be> |
|
|
20 |
*/ |
|
|
21 |
class JsonEncoder implements EncoderInterface, DecoderInterface |
|
|
22 |
{ |
|
|
23 |
/** |
|
|
24 |
* {@inheritdoc} |
|
|
25 |
*/ |
|
|
26 |
public function encode($data, $format) |
|
|
27 |
{ |
|
|
28 |
return json_encode($data); |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
/** |
|
|
32 |
* {@inheritdoc} |
|
|
33 |
*/ |
|
|
34 |
public function decode($data, $format) |
|
|
35 |
{ |
|
|
36 |
return json_decode($data, true); |
|
|
37 |
} |
|
|
38 |
} |