generator

abstract fun generator(): String

An optional custom generator tag used to indicate which generator should be used. If empty,Moshi's annotation processor will generate an adapter for the annotated type. If not empty,Moshi's processor will skip it and defer to a custom generator. This can be used to allow othercustom code generation tools to run and still allow Moshi to read their generated JsonAdapteroutputs.

Requirements for generated adapter class signatures:

  • The generated adapter must subclass JsonAdapter and be parameterized by thistype.
  • generatedJsonAdapterName should be used for the fully qualified class namein order for Moshi to correctly resolve and load the generated JsonAdapter.
  • The first parameter must be a Moshi instance.
  • If generic, a second Type[] parameter should be declared to accept typearguments.

Example for a class "CustomType":

{@code * class CustomTypeJsonAdapter(moshi: Moshi, types: Array) : JsonAdapter

To help ensure your own generator meets requirements above, you can use Moshi’s built-ingenerator to create the API signature to get started, then make your own generator match thatexpected signature.