Json5Decoder
in package
Table of Contents
- $associative : mixed
- $at : mixed
- $castBigIntToString : mixed
- $currentByte : mixed
- $currentLineStartsAt : mixed
- $depth : mixed
- $json : mixed
- $length : mixed
- $lineNumber : mixed
- $maxDepth : mixed
- decode() : mixed
- Takes a JSON encoded string and converts it into a PHP variable.
- __construct() : mixed
- Private constructor.
- arr() : mixed
- blockComment() : mixed
- Skip a block comment, assuming this is one.
- comment() : mixed
- Skip a comment, whether inline or block-level, assuming this is one.
- currentChar() : string|null
- getByte() : null
- getEscapee() : string|null
- identifier() : mixed
- Parse an identifier.
- inlineComment() : mixed
- Skip an inline comment, assuming this is one.
- match() : string|null
- Attempt to match a regular expression at the current position on the current line.
- next() : null|string
- Parse the next character.
- nextOrFail() : string|null
- Parse the next character if it matches $c or fail.
- number() : mixed
- obj() : mixed
- Parse an object value
- peek() : mixed
- Get the next character without consuming it or assigning it to the ch variable.
- renderChar() : mixed
- string() : mixed
- throwSyntaxError() : mixed
- value() : mixed
- Parse a JSON value.
- white() : mixed
- Skip whitespace and comments.
- word() : mixed
- Matches true, false, null, etc
Properties
$associative
private
mixed
$associative
= false
$at
private
mixed
$at
= 0
$castBigIntToString
private
mixed
$castBigIntToString
= false
$currentByte
private
mixed
$currentByte
$currentLineStartsAt
private
mixed
$currentLineStartsAt
= 0
$depth
private
mixed
$depth
= 1
$json
private
mixed
$json
$length
private
mixed
$length
$lineNumber
private
mixed
$lineNumber
= 1
$maxDepth
private
mixed
$maxDepth
= 512
Methods
decode()
Takes a JSON encoded string and converts it into a PHP variable.
public
static decode(string $source[, bool $associative = false ][, int $depth = 512 ], int $options) : mixed
The parameters exactly match PHP's json_decode() function - see http://php.net/manual/en/function.json-decode.php for more information.
Parameters
- $source : string
-
The JSON string being decoded.
- $associative : bool = false
-
When TRUE, returned objects will be converted into associative arrays.
- $depth : int = 512
-
User specified recursion depth.
- $options : int
-
Bitmask of JSON decode options.
Return values
mixed —__construct()
Private constructor.
private
__construct(string $json[, bool $associative = false ][, int $depth = 512 ][, bool $castBigIntToString = false ]) : mixed
Parameters
- $json : string
- $associative : bool = false
- $depth : int = 512
- $castBigIntToString : bool = false
Return values
mixed —arr()
private
arr() : mixed
Return values
mixed —blockComment()
Skip a block comment, assuming this is one.
private
blockComment() : mixed
The current character should be the * character in the /* pair that begins this block comment. To finish the block comment, we look for an ending */ pair of characters, but we also watch for the end of text before the comment is terminated.
Return values
mixed —comment()
Skip a comment, whether inline or block-level, assuming this is one.
private
comment() : mixed
Return values
mixed —currentChar()
private
currentChar() : string|null
Return values
string|null —getByte()
private
getByte(int $at) : null
Parameters
- $at : int
Return values
null —getEscapee()
private
static getEscapee(string $ch) : string|null
Parameters
- $ch : string
Return values
string|null —identifier()
Parse an identifier.
private
identifier() : mixed
Normally, reserved words are disallowed here, but we only use this for unquoted object keys, where reserved words are allowed, so we don't check for those here. References:
- http://es5.github.com/#x7.6
- https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Variables
- http://docstore.mik.ua/orelly/webprog/jscript/ch02_07.htm
Return values
mixed —inlineComment()
Skip an inline comment, assuming this is one.
private
inlineComment() : mixed
The current character should be the second / character in the // pair that begins this inline comment. To finish the inline comment, we look for a newline or the end of the text.
Return values
mixed —match()
Attempt to match a regular expression at the current position on the current line.
private
match(string $regex) : string|null
This function will not match across multiple lines.
Parameters
- $regex : string
Return values
string|null —next()
Parse the next character.
private
next() : null|string
Return values
null|string —nextOrFail()
Parse the next character if it matches $c or fail.
private
nextOrFail(string $c) : string|null
Parameters
- $c : string
Return values
string|null —number()
private
number() : mixed
Return values
mixed —obj()
Parse an object value
private
obj() : mixed
Return values
mixed —peek()
Get the next character without consuming it or assigning it to the ch variable.
private
peek() : mixed
Return values
mixed —renderChar()
private
static renderChar(mixed $chr) : mixed
Parameters
- $chr : mixed
Return values
mixed —string()
private
string() : mixed
Return values
mixed —throwSyntaxError()
private
throwSyntaxError(mixed $message) : mixed
Parameters
- $message : mixed
Return values
mixed —value()
Parse a JSON value.
private
value() : mixed
It could be an object, an array, a string, a number, or a word.
Return values
mixed —white()
Skip whitespace and comments.
private
white() : mixed
Note that we're detecting comments by only a single / character. This works since regular expressions are not valid JSON(5), but this will break if there are other valid values that begin with a / character!
Return values
mixed —word()
Matches true, false, null, etc
private
word() : mixed