Options
All
  • Public
  • Public/Protected
  • All
Menu

Contains methods that allow us to convert data from one complex data structure format to another complex data structure format

Hierarchy

  • SerializationManager

Index

Properties

strictMode

strictMode: boolean = true

When set to true, the structures that are passed as serialization sources must match the structures that are passed as serialization targets: All keys or properties that are defined on the serialization sources must exist on the serialization targets, otherwise an exception will be thrown

Methods

classToJson

  • classToJson(classInstance: any): string
  • Generate a valid JSON string from a given class instance

    Parameters

    • classInstance: any

      A class instance

    Returns string

    A valid JSON string containing all the data on the provided class

classToObject

  • classToObject(): void
  • Returns void

javaPropertiesObjectToString

  • Convert a JavaPropertiesObject instance to a string that is valid so it can be saved to a .properties file.

    Parameters

    Returns string

    An ISO-8859-1 string containing valid properties data, ready to be stored as a .properties java format file.

jsonToClass

  • jsonToClass<T>(string: string, classInstance: T): T
  • Copy data from a json string to a class instance. All class properties will be filled with the values from the json For more information on how the conversion is performed, see this class objectToClass method

    see

    SerializationUtils.objectToClass

    Type parameters

    • T

    Parameters

    • string: string

      A string containing valid json data

    • classInstance: T

      A class instance that will be filled with all the json data (the instance is modified by this method and all values erased).

    Returns T

    The provided class instance with all its properties filled with the corresponding json values

objectToClass

  • objectToClass(object: Object, classInstance: any): any
  • Copy data from an object instance to a class instance. All class properties will be filled with the values from the object.

    If a property from the class instance contains a default value, it will be used as a reference to restrict the value type. If the same key on the object has a different type value, an exception will happen. Null values on the source object keys will leave the same destination class properties untouched.

    Typed arrays can be forced by setting a class property as an array with a single default item. That item type will be used as the reference for all the array values on the object property.

    Parameters

    • object: Object

      An object containing the source data to serialize

    • classInstance: any

      An empty class instance that will be filled with all the values from the object

    Returns any

    The provided class instance with all its properties filled with the corresponding object values

stringToJavaPropertiesObject

  • Convert a string containing the contents of a Java properties file to a JavaPropertiesObject instance Note that the input string must be encoded with ISO-8859-1 and strictly follow the Java properties file format (Otherwise results may not be correct).

    Parameters

    • string: string

      String containing the contents of a .properties Java file

    Returns JavaPropertiesObject

    The properties format parsed as an object

Generated using TypeDoc