DiscriminatorKind

zio.blocks.schema.json.DiscriminatorKind
See theDiscriminatorKind companion object
sealed trait DiscriminatorKind

Represents the strategy for specifying the discriminator used in a JSON schema for distinguishing between different subtypes of a sealed hierarchy.

Implementations of this trait define how the discriminator is represented in the serialized JSON, if any.

The possible discriminator kinds include:

  • Field with adding a custom field named as specified in the name parameter that contains a value of the subtype discriminator, e.g. {"type": "Person", ...} for case class Person(...) extends SealedTrait
  • Key, where the discriminator is represented as a JSON object key with wrapping of the encoded value in a JSON object, e.g. {"Person":{...}} for case class Person(...) extends SealedTrait.
  • None, where no discriminator is used, meaning subtype differentiation is handled by sequential attempts to parse all possible subtypes, starting from the first subtype, until a successful parse is found, or an error is thrown if none of the subtypes can be parsed from the input.

Attributes

Companion
object
Source
DiscriminatorKind.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Field
object Key
object None
In this article