Version 1
[yaffs-website] / web / modules / contrib / devel / kint / kint / parsers / custom / json.php
diff --git a/web/modules/contrib/devel/kint/kint/parsers/custom/json.php b/web/modules/contrib/devel/kint/kint/parsers/custom/json.php
new file mode 100644 (file)
index 0000000..f752a21
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+class Kint_Parsers_Json extends kintParser
+{
+       protected function _parse( & $variable )
+       {
+               if ( !KINT_PHP53
+                       || !is_string( $variable )
+                       || !isset( $variable{0} ) || ( $variable{0} !== '{' && $variable{0} !== '[' )
+                       || ( $json = json_decode( $variable, true ) ) === null
+               ) return false;
+
+               $val = (array) $json;
+               if ( empty( $val ) ) return false;
+
+               $this->value = kintParser::factory( $val )->extendedValue;
+               $this->type  = 'JSON';
+       }
+}
\ No newline at end of file