@openhps/rdf
    Preparing search index...

    Interface SerializableObjectOptions<T>

    interface SerializableObjectOptions<T> {
        beforeSerialization?: string;
        initializer?: InitializerCallback<T>;
        knownTypes?: Function[];
        name?: string;
        onDeserialized?: string;
        preserveNull?: boolean;
        rdf?: {
            deserializer?: (thing: Thing, instance?: T) => T;
            predicates?: Record<IriString, IriString[]>;
            query?: string;
            serializer?: (
                object: T,
                baseUri?: `http://${string}` | `https://${string}`,
            ) => Quad_Object | Partial<Thing>;
            type?:
                | `http://${string}`
                | `https://${string}`
                | (`http://${string}` | `https://${string}`)[];
            typeResolver?: (thing: Thing) => boolean;
        };
        typeHintEmitter?: TypeHintEmitter;
        typeResolver?: TypeResolver;
    }

    Type Parameters

    • T

    Hierarchy

    • IJsonObjectOptions<T>
      • SerializableObjectOptions
    Index

    Properties

    beforeSerialization?: string

    The name of a static or instance method to call before the serialization of the typed object is started.

    initializer?: InitializerCallback<T>

    Function to call before deserializing and initializing the object, accepting two arguments: (1) sourceObject, an 'Object' instance with all properties already deserialized, and (2) rawSourceObject, a raw 'Object' instance representation of the current object in the serialized JSON (i.e. without deserialized properties).

    knownTypes?: Function[]

    An array of known types to recognize when encountering type-hints.

    name?: string

    The name used to differentiate between different polymorphic types.

    onDeserialized?: string

    The name of a static or instance method to call when deserialization of the object is completed.

    preserveNull?: boolean

    Whether to preserve null in the JSON output. When false it will not emit nor store the property if its value is null. Default: false.

    rdf?: {
        deserializer?: (thing: Thing, instance?: T) => T;
        predicates?: Record<IriString, IriString[]>;
        query?: string;
        serializer?: (
            object: T,
            baseUri?: `http://${string}` | `https://${string}`,
        ) => Quad_Object | Partial<Thing>;
        type?:
            | `http://${string}`
            | `https://${string}`
            | (`http://${string}` | `https://${string}`)[];
        typeResolver?: (thing: Thing) => boolean;
    }

    Resource Description Framework serialization options

    Type Declaration

    • Optionaldeserializer?: (thing: Thing, instance?: T) => T

      Custom (partial) deserializer for this object.

    • Optionalpredicates?: Record<IriString, IriString[]>

      Additional static predicates to add to this object that are not based on any properties inside the object.

    • Optionalquery?: string

      Custom SPARQL query to deserialize this object

    • Optionalserializer?: (
          object: T,
          baseUri?: `http://${string}` | `https://${string}`,
      ) => Quad_Object | Partial<Thing>

      Custom (partial) serializer for this object.

    • Optionaltype?:
          | `http://${string}`
          | `https://${string}`
          | (`http://${string}` | `https://${string}`)[]

      RDF type of this class. This will be automatically added as a static predicate.

    • OptionaltypeResolver?: (thing: Thing) => boolean

      Type resolver for deserialized thing. Return true if the type matches and false if the type does not match.

    typeHintEmitter?: TypeHintEmitter

    A function that will emit a type hint on the resulting JSON. It will override the global typeEmitter.

    typeResolver?: TypeResolver

    A function that given a source object will resolve the type that should be instantiated. It will override the global type resolver.