Interface JSONVisitor
onArrayBegin?: (
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => boolean | void;
onArrayEnd?: (
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void;
onComment?: (
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void;
onError?: (
error: ParseErrorCode,
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void;
onLiteralValue?: (
value: any,
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => void;
onObjectBegin?: (
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => boolean | void;
onObjectEnd?: (
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void;
onObjectProperty?: (
property: string,
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => void;
onSeparator?: (
character: string,
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void;
}
Properties
OptionalonArrayBegin
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => boolean | void
Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket.
When false is returned, the array items will not be visited.
OptionalonArrayEnd
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void
Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket.
OptionalonComment
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void
When comments are allowed, invoked when a line or block comment is encountered. The offset and length represent the location of the comment.
OptionalonError
error: ParseErrorCode,
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void
Invoked on an error.
OptionalonLiteralValue
value: any,
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => void
Invoked when a literal value is encountered. The offset and length represent the location of the literal value.
OptionalonObjectBegin
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => boolean | void
Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace.
When false is returned, the object properties will not be visited.
OptionalonObjectEnd
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void
Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace.
OptionalonObjectProperty
property: string,
offset: number,
length: number,
startLine: number,
startCharacter: number,
pathSupplier: () => JSONPath,
) => void
Invoked when a property is encountered. The offset and length represent the location of the property name.
The JSONPath created by the pathSupplier refers to the enclosing JSON object, it does not include the
property name yet.
OptionalonSeparator
character: string,
offset: number,
length: number,
startLine: number,
startCharacter: number,
) => void
Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator.
Visitor called by
visitwhen parsing JSON.The visitor functions have the following common parameters:
offset: Global offset within the JSON document, starting at 0startLine: Line number, starting at 0startCharacter: Start character (column) within the current line, starting at 0Additionally some functions have a
pathSupplierparameter which can be used to obtain the currentJSONPathwithin the document.