AdonisJS API
    Preparing search index...

    Representation of a value object that can be serialized to JSON via a toJSON method.

    type CanBeSerialized<T extends JSONDataTypes> = {
        toJSON(): T;
    }

    Type Parameters

    • T extends JSONDataTypes

      The type that the toJSON method should return

      class User implements CanBeSerialized<{ id: number; name: string }> {
      constructor(private id: number, private name: string) {}

      toJSON() {
      return { id: this.id, name: this.name }
      }
      }
    Index
    • Converts the object to a JSON-serializable representation

      Returns T