blob: d015cc1802e9bfb23c0db3eae4a8ae20ba4cf408 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<?php
namespace WFlywheel\Formatter;
class JSON implements \JamesMoss\Flywheel\Formatter\FormatInterface
{
public function getFileExtension()
{
return 'json';
}
public function encode(array $data)
{
$options = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
$options .= JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE;
return json_encode($data, $options);
}
public function decode($data)
{
$options = defined('JSON_OBJECT_AS_ARRAY') ? JSON_OBJECT_AS_ARRAY : null;
return json_decode($data, $options);
}
}
|