Package-level declarations

Types

Link copied to clipboard

Annotation to be placed on enum an enum value or sealed class subclass to indicate that it is the default value if an unknown or missing entry is encountered.

Link copied to clipboard
annotation class JsonProperty(val name: String)

Can be added to a data class property or enum instance to specify the name that is used when serializing it to and from JSON.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class JsonSerializable(val useAdaptersForPrimitives: PrimitiveAdapters = PrimitiveAdapters.DEFAULT, val serializeNulls: SerializeNulls = SerializeNulls.DEFAULT)

Annotation to be placed on classes that Kotshi should generate a JsonAdapter for.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class KotshiJsonAdapterFactory(val useAdaptersForPrimitives: Boolean = false, val serializeNulls: SerializeNulls = SerializeNulls.DEFAULT)

Annotation to be applied on an abstract class that implements JsonAdapter.Factory to tell Kotshi to generate a factory containing all adapters in this module.

Link copied to clipboard

A helper class for Kotshi.

Link copied to clipboard
abstract class NamedJsonAdapter<T : Any> : JsonAdapter<T>

A JsonAdapter that implements toString. This class is here to avoid adding one extra method per generated adapter.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class Polymorphic(val labelKey: String, val onMissing: Polymorphic.Fallback = Fallback.DEFAULT, val onInvalid: Polymorphic.Fallback = Fallback.DEFAULT)

Annotation to be placed on a sealed class to describe how it should be parsed.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class PolymorphicLabel(val value: String)

An annotation must be applied to subtypes of a sealed class to specify the value that represents the type.

Link copied to clipboard

Flag for enabling/disabling the use of adapters for primitive types.

Link copied to clipboard
annotation class RegisterJsonAdapter(val priority: Int = 0)

Registers the annotated type in the Kotshi json adapter factory. All registered adapters take priority over all generated adapters.

Link copied to clipboard

Flag for enabling/disabling null serialization. Can be applied both to a factory or to individual adapters.