Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JsonStringifier<T>

JsonStringifier provides functionality for writing 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

  • JsonStringifier

Index

Constructors

constructor

  • new JsonStringifier(defaultContext?: JsonStringifierContext): JsonStringifier

Properties

defaultContext

defaultContext: JsonStringifierContext

Default context to use during serialization.

Methods

stringify

  • stringify(obj: T, context?: JsonStringifierContext): string
  • Method for serializing a JavaScript object or a value to a JSON string.

    Parameters

    • obj: T

      the JavaScript object or value to be serialized.

    • Optional context: JsonStringifierContext

      the context to be used during serialization.

    Returns string

transform

  • transform(value: any, context?: JsonStringifierContext): any
  • Method for applying json decorators to a JavaScript object/value. It returns a JavaScript object/value with json decorators applied and ready to be JSON serialized.

    Parameters

    • value: any

      the JavaScript object or value to be preprocessed.

    • Optional context: JsonStringifierContext

      the context to be used during serialization preprocessing.

    Returns any

Static makeDefaultContext

  • makeDefaultContext(): JsonStringifierContext

Static mergeContexts

  • mergeContexts(contexts: JsonStringifierContext[]): JsonStringifierContext
  • Merge multiple {@link JsonStringifierContext} 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 JsonStringifierContext.mainCreator}, will be completely replaced.

    Parameters

    • contexts: JsonStringifierContext[]

      list of contexts to be merged.

    Returns JsonStringifierContext

Generated using TypeDoc