json.php 456 B

12345678910111213141516171819
  1. <?php
  2. class Kint_Parsers_Json extends kintParser
  3. {
  4. protected function _parse( & $variable )
  5. {
  6. if ( !KINT_PHP53
  7. || !is_string( $variable )
  8. || !isset( $variable{0} ) || ( $variable{0} !== '{' && $variable{0} !== '[' )
  9. || ( $json = json_decode( $variable, true ) ) === null
  10. ) return false;
  11. $val = (array) $json;
  12. if ( empty( $val ) ) return false;
  13. $this->value = kintParser::factory( $val )->extendedValue;
  14. $this->type = 'JSON';
  15. }
  16. }