diff options
Diffstat (limited to 'app/class/Flywheel/Formatter/JSON.php')
-rw-r--r-- | app/class/Flywheel/Formatter/JSON.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/class/Flywheel/Formatter/JSON.php b/app/class/Flywheel/Formatter/JSON.php new file mode 100644 index 0000000..9659fcb --- /dev/null +++ b/app/class/Flywheel/Formatter/JSON.php @@ -0,0 +1,21 @@ +<?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); + } +}
\ No newline at end of file |