Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Methods

mergeValue

  • mergeValue<T>(key: keyof T & string, model: T): void
  • By default, this method looks for a merge<Key>FromModel method on the receiver, and invokes it if found. If not found, and model is not null, the value for the given key is taken from model.

    Type parameters

    Parameters

    • key: keyof T & string

      the name of the property to merge.

    • model: T

      the model to merge from.

    Returns void

mergeValues

  • mergeValues<T>(model: T): void

toJSON

  • toJSON(): any
  • Serializes a model into an object.

    Note: This does not throw the error if it occurs during serialization. Check Model.toObject if you need that.

    Returns any

toObject

  • toObject(): any
  • Serializes a model into an object.

    Returns any

validate

  • validate(): boolean
  • Validates the model.

    The default implementation simply invokes validate<Key> for all keys in Serializable.JSONKeyPaths.

    Returns boolean

    true if the model is valid, false otherwise.

Static JSONKeyPaths

  • JSONKeyPaths(): object
  • Specifies how to map property keys to different key paths in JSON.

    Values in the object can either be key paths in the JSON representation of the receiver or an array of such key paths. If an array is used, the deserialized value will be an object containing all of the keys in the array.

    Any keys omitted will not participate in JSON serialization.

    example
    
    public static JSONKeyPaths() {
        return {
            name: "POI.name",
            point: ["latitude", "longitude"],
            starred: "starred",
        };
    }
    

    Returns object

    • [key: string]: string | string[]

Static Optional JSONTransformerForKey

  • Specifies how to convert a JSON value to the given property key. If reversible, the transformer will also be used to convert the property value back to JSON.

    If the receiver implements a <key>JSONTransformer method, the result of that method will be used instead.

    Parameters

    • key: string

      the name of the property.

    Returns ValueTransformer | undefined

    a value transformer, or undefined if no transformation should be performed.

Static Optional classForParsingObject

  • classForParsingObject<T>(json: any): Newable<T>
  • Overridden to parse the receiver as a different class, based on information in the provided object.

    This is mostly useful for class clusters, where the abstract base class would be passed, but a subclass should be instantiated instead.

    Type parameters

    Parameters

    • json: any

      object to check the class for.

    Returns Newable<T>

    the class that should be parsed (which may be the receiver), or undefined to abort parsing (e.g. if the data is invalid).

Static create

  • create<T>(this: Newable<T>, json: Partial<T>): T | null
  • Initializes a model with the given object.

    Type parameters

    Parameters

    • this: Newable<T>
    • json: Partial<T>

      An object.

    Returns T | null

Static from

  • from<T>(this: Newable<T>, json: any): T | null
  • Deserializes a model from an object.

    Type parameters

    Parameters

    • this: Newable<T>
    • json: any

      An object.

    Returns T | null

Static fromArray

  • fromArray<T>(this: Newable<T>, json: any[]): T[] | null
  • Attempts to parse an array of objects into model objects of a specific class.

    Type parameters

    Parameters

    • this: Newable<T>
    • json: any[]

      An array of objects.

    Returns T[] | null

Static toArray

  • toArray<T>(this: Newable<T>, models: T[]): any[] | null
  • Converts an array of models into an object array.

    Type parameters

    Parameters

    • this: Newable<T>
    • models: T[]

      An array of models to use for JSON serialization.

    Returns any[] | null

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc