node-json-db
    Preparing search index...

    Contract for custom type serialization/deserialization. Implement this interface to add support for custom types that are not natively supported by JSON.

    Types are serialized using a __type discriminator:

    { "__type": "TypeName", "__value": <serialized-data> }
    
    interface ISerializer {
        type: string;
        deserialize(value: any): any;
        serialize(value: any): any;
        test(value: any): boolean;
    }

    Implemented by

    Index

    Properties

    Methods

    Properties

    type: string

    Unique type identifier stored as __type in the serialized JSON.

    Methods

    • Deserialize a value from its JSON representation. The input is the __value from the serialized JSON.

      Parameters

      • value: any

        The stored JSON value

      Returns any

      The deserialized runtime value

    • Serialize a value to a JSON-compatible representation. The returned value will be stored under __value in the serialized JSON.

      Parameters

      • value: any

        The value to serialize

      Returns any

      A JSON-compatible value

    • Test if a runtime value should be handled by this serializer.

      Parameters

      • value: any

        The value to test

      Returns boolean

      true if this serializer should handle this value