Class JsonMapper

Class for JSON Mapping.

Export

Hierarchy

  • JsonMapper

Constructors

Methods

  • Deserialization method. Deserializes source into an object built using ctor.

    Annotated properties are deserialized into a property using the name value as the source name (defaults to the property name).

    Type Parameters

    • T

      the type of output object

    Parameters

    • ctor: Constructable<T, any[]>

      the destination constructor

    • source: string | object

      the value to be deserialized

    • stringParser: ((s) => any) = JSON.parse

      the string parser to deserialize strings into JSON objects. Defaults to JSON.parse.

        • (s): any
        • Parameters

          • s: string

          Returns any

    Returns T

    the deserialized object

    Throws

    An error if a class encountered while deserializing has no JsonClass decorator.

    Memberof

    JsonMapper

  • Deserializes an array by applying deserialize to each element.

    Type Parameters

    • T

      the type of output object

    Parameters

    • ctor: Constructable<T, any[]>

      the destination constructor

    • jsonArray: any[]

      the array to be deserialized

    Returns T[]

    the deserialized object

    Memberof

    JsonMapper

  • Serialization method. Transforms source into a new JSON value by applying the "serialization" step for each property decorator.

    Annotated properties are serialized into a property using the name value as the destination name (defaults to the property name).

    Parameters

    • source: any

      the value to be serialized.

    Returns any

    the transformed JSON value.

    Throws

    An error if a class encountered while serializing has no JsonClass decorator.

    Memberof

    JsonMapper

Generated using TypeDoc