blob: d55c3b61089644c279cba587c37324a151aa2b67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<?php
namespace Wcms\Flywheel\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);
}
}
|