In This Article

JsonParser Class

Represents a parser for the JSON language.

public class JsonParser : LLParserBase, ILLParser, IParser, IKeyedObject
Inheritance:
object ParserBase LLParserBase object
Implements:
ILLParser IParser IKeyedObject

Constructors

JsonParser()

Initializes a new instance of the JsonParser class.

public JsonParser()

JsonParser(Grammar)

Initializes a new instance of the JsonParser class.

public JsonParser(Grammar grammar)
Parameter Type Description
grammar Grammar

The Grammar instance to use.

Properties

AreCommentsSupported

Gets or sets whether comments can recognized and tokenized by the lexer created in CreateTokenReader(ITextBufferReader).

public bool AreCommentsSupported { get; set; }

Property Value

bool:

true if comments can recognized and tokenized by the lexer; otherwise, false. The default value is false.

Remarks

Comments are not supported by standard JSON, and are therefore lexer support is not enabled by default. However JavaScript style comments are supported by Microsoft's JSONC (JSON with Comments) variant. Set this property to true to allow the lexer to recognize comment tokens.

Methods

CreateParseData(IParseRequest, IParserState)

Creates an IParseData for the specified IParserState.

protected override IParseData CreateParseData(IParseRequest request, IParserState state)
Parameter Type Description
request IParseRequest

The IParseRequest that contains data about the requested parsing operation.

state IParserState

The IParserState to examine.

Returns

IParseData:

The IParseData that was created.

CreateTokenReader(ITextBufferReader)

Creates an ITokenReader that is used by the parser to read through tokens.

public override ITokenReader CreateTokenReader(ITextBufferReader reader)
Parameter Type Description
reader ITextBufferReader

The ITextBufferReader that provides access to the text buffer.

Returns

ITokenReader:

An ITokenReader that is used by the parser to read through tokens.

InitializeParserState(IParserState, IParseRequest)

Initializes the IParserState, allowing its CustomData property to be configured based on data from the IParseRequest, immediately prior to the parse operation running.

protected override void InitializeParserState(IParserState state, IParseRequest request)
Parameter Type Description
state IParserState

The IParserState to initialize.

request IParseRequest

The IParseRequest that initiated the parse operation.

Inherited Members