Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JsonParser<T>

JsonParser provides functionality for reading JSON. It is also highly customizable to work both with different styles of JSON content, and to support more advanced Object concepts such as polymorphism and Object identity.

Type parameters

  • T

Hierarchy

  • JsonParser

Index

Constructors

constructor

  • new JsonParser(defaultContext?: JsonParserContext): JsonParser
  • Parameters

    • Default value defaultContext: JsonParserContext = JsonParser.makeDefaultContext()

      Default context to use during deserialization.

    Returns JsonParser

Properties

defaultContext

defaultContext: JsonParserContext

Default context to use during deserialization.

Methods

parse

  • parse(text: string, context?: JsonParserContext): T
  • Method for deserializing a JSON string into a JavaScript object or value.

    Parameters

    • text: string

      the JSON string to be deserialized.

    • Optional context: JsonParserContext

      the context to be used during deserialization.

    Returns T

transform

  • transform(value: any, context?: JsonParserContext): any
  • Method for applying json decorators to a JavaScript object/value parsed. It returns a JavaScript object/value with json decorators applied.

    Parameters

    • value: any

      the JavaScript object or value to be postprocessed.

    • Optional context: JsonParserContext

      the context to be used during deserialization postprocessing.

    Returns any

Static makeDefaultContext

  • makeDefaultContext(): JsonParserContext

Static mergeContexts

  • mergeContexts(contexts: JsonParserContext[]): JsonParserContext
  • Merge multiple {@link JsonParserContext} into one. Array direct properties will be concatenated, instead, Map and Object Literal direct properties will be merged. All the other properties, such as {@link JsonParserContext.mainCreator}, will be completely replaced.

    Parameters

    • contexts: JsonParserContext[]

      list of contexts to be merged.

    Returns JsonParserContext

Generated using TypeDoc