serializr
    Preparing search index...

    Function serializable

    • Decorator that defines a new property mapping on the default model schema for the class it is used in.

      When using typescript, the decorator can also be used on fields declared as constructor arguments (using the private / protected / public keywords). The default factory will then invoke the constructor with the correct arguments as well.

      Parameters

      Returns (target: any, key: string, baseDescriptor?: PropertyDescriptor) => void

      class Todo {
      @serializable(primitive())
      title // shorthand for primitves

      @serializable
      done

      constructor(title, done) {
      this.title = title
      this.done = done
      }
      }

      const json = serialize(new Todo('Test', false))
      const todo = deserialize(Todo, json)
    • Decorator that defines a new property mapping on the default model schema for the class it is used in.

      When using typescript, the decorator can also be used on fields declared as constructor arguments (using the private / protected / public keywords). The default factory will then invoke the constructor with the correct arguments as well.

      Parameters

      • target: any
      • key: string
      • OptionalbaseDescriptor: PropertyDescriptor

      Returns void

      class Todo {
      @serializable(primitive())
      title // shorthand for primitves

      @serializable
      done

      constructor(title, done) {
      this.title = title
      this.done = done
      }
      }

      const json = serialize(new Todo('Test', false))
      const todo = deserialize(Todo, json)