aboutsummaryrefslogtreecommitdiff
path: root/app/class/wflywheel/formatter
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/wflywheel/formatter')
-rw-r--r--app/class/wflywheel/formatter/json.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/class/wflywheel/formatter/json.php b/app/class/wflywheel/formatter/json.php
new file mode 100644
index 0000000..8583802
--- /dev/null
+++ b/app/class/wflywheel/formatter/json.php
@@ -0,0 +1,20 @@
+<?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;
+ 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