Skip to main content

SipaSerializer

SipaSerializer

Serializer to serialize data of primitive types or even complex Objects, to ensure to be stored as valid JSON and can be deserialized back without data loss.

Includes support for

  • Boolean, Number, String, Array, Object, null (native JS[SON] support) And special type handling to support the following types
  • Functions
  • RegExp, Date
  • NaN, Infinity, undefined
  • empty (special type when deleting an item of an array)

The special types are escaped by an internal escaping when serialized. See SipaSerializer.STORAGE_PLACEHOLDERS for the escapes.

SipaSerializer.serialize(value) string | null

Serialize given value to be stored in JSON without loosing its original value

Returns: string | null - returns string or null if value is null

ParamType
valueany

SipaSerializer.deserialize(value) Boolean | String | Number | Array | Object | RegExp | Date | undefined | NaN | Infinity | null | *

Serialize given value to be stored in JSON without loosing its original value

ParamType
valueString | null

SipaSerializer.isFunctionString(value) boolean

Check if given string is a valid javascript function

ParamType
valueString

SipaSerializer.isArrayString(value) boolean

Check if given string is a valid javascript array

ParamType
valueString

SipaSerializer.isObjectString(value) boolean

Check if given string is a valid javascript object

ParamType
valueString

SipaSerializer.deserializeFunctionString(value) function

Deserialize a valid javascript string into a callable function

ParamType
valueString

SipaSerializer.deepSerializeSpecialTypes(obj) Array | Object

Serializes (escapes) all special types within an Array or Object to be stored in JSON without data loss.

Original Array or Object is cloned and will not be manipulated.

ParamType
objArray | Object

SipaSerializer.deepDeserializeSpecialTypes(obj) Array | Object

Deserializes (unescapes) all special types of the given Array or Object

Original Array or Object is cloned and will not be manipulated.

ParamType
objArray | Object