Documentation

JSON
in package

FinalYes

JSON parser and utility parsers

Tags
TODO

fix psalm annotations

psalm-immutable

Table of Contents

Methods

array()  : Parser
element()  : Parser
false()  : Parser
json()  : Parser
Fully compliant JSON parser, built entirely in Parsica. The output is compatible with PHP's native json_decode().
member()  : Parser<string|int, array{string: mixed}>
null()  : Parser
number()  : Parser
object()  : Parser
stringLiteral()  : Parser
token()  : Parser
Apply $parser and consume all the following whitespace.
true()  : Parser
ws()  : Parser
Whitespace
__construct()  : mixed

Methods

array()

public static array() : Parser
Tags
psalm-return

Parser<list>

Return values
Parser

element()

public static element() : Parser
Tags
template
psalm-return

Parser

psalm-suppress

DocblockTypeContradiction

Return values
Parser

false()

public static false() : Parser
Tags
psalm-return

Parser

Return values
Parser

json()

Fully compliant JSON parser, built entirely in Parsica. The output is compatible with PHP's native json_decode().

public static json() : Parser
APIYes

It was built to illustrate the usage of Parsica on a real world format, and to benchmark Parsica against json_decode(). It will probably never reach the same performance as a C extension, so it shouldn't be used for typical production JSON parsing.

It could however be useful as a basis to expand into a custom JSON parser, for example to expand JSON with custom notations or comments, or to return a custom AST instead of json_decode()'s plain PHP objects & arrays.

To understand the terminology and the structure, have a peak at https://www.json.org/json-en.html

Tags
psalm-return

Parser

Return values
Parser

member()

public static member() : Parser<string|int, array{string: mixed}>
Return values
Parser<string|int, array{string: mixed}>

object()

public static object() : Parser
Tags
psalm-return

Parser

Return values
Parser

stringLiteral()

public static stringLiteral() : Parser
Tags
psalm-return

Parser

Return values
Parser

token()

Apply $parser and consume all the following whitespace.

public static token(Parser $parser) : Parser
Parameters
$parser : Parser
Tags
template
psalm-param

Parser<T> $parser

psalm-return

Parser<T>

Return values
Parser

ws()

Whitespace

public static ws() : Parser
Tags
psalm-return

Parser

Return values
Parser

__construct()

private __construct() : mixed

        
On this page

Search results