/** * Decodes the specified JSON string into an native PHP type. * * @codeCoverageIgnore * @param string $str JSON string to parse. * @return Mixed Native PHP type based on JSON data. */ public static function decode($str) { if (function_exists('json_decode')) { return json_decode($str); } // Fall back to custom JsonDecoder logic return MOXMAN_Util_JsonDecoder::decode($str); }
/** @ignore */ private static function readNumber($start) { $value = ""; $isFloat = false; self::$token = self::TOKEN_INT; $value .= $start; while (($chr = self::peek()) !== null) { // Ignore whitespace if ($chr === " " || $chr === "\t" || $chr === "\r" || $chr === "\n") { self::read(); continue; } if (is_numeric($chr) || $chr === '-' || $chr === '.' || $chr === "e" || $chr === "E" || $chr === "+") { if ($chr == '.') { $isFloat = true; } $value .= self::read(); } else { break; } } self::readAway(); if ($isFloat) { self::$token = self::TOKEN_FLOAT; self::$value = floatval($value); } else { self::$value = intval($value); } if (self::$location == self::LOC_IN_OBJECT && !self::$needProp) { self::$needProp = true; } return true; }