OptionDecoder

final class OptionDecoder[A](implicit A: Decoder[A]) extends Decoder[Option[A]]

A decoder for Option[A].

This is modeled as a separate, named, subtype because Option decoders often have special semantics around the handling of JNull. By having this as a named subtype, we premit certain optimizations that would otherwise not be possible. See circe-generic-extras for some examples.

Source:
Decoder.scala
trait Decoder[Option[A]]
trait Serializable
class Object
trait Matchable
class Any

Value members

Concrete methods

final override def apply(c: HCursor): Result[Option[A]]
Definition Classes
Source:
Decoder.scala
Definition Classes
Source:
Decoder.scala
final override def tryDecode(c: ACursor): Result[Option[A]]
Definition Classes
Source:
Decoder.scala
Definition Classes
Source:
Decoder.scala

Inherited methods

final def at(field: String): Decoder[Option[A]]

Create a new decoder that attempts to navigate to the specified field before decoding.

Create a new decoder that attempts to navigate to the specified field before decoding.

Inherited from:
Decoder
Source:
Decoder.scala
final def decodeJson(j: Json): Result[Option[A]]

Decode the given Json value.

Decode the given Json value.

Inherited from:
Decoder
Source:
Decoder.scala
final def either[B](decodeB: Decoder[B]): Decoder[Either[Option[A], B]]

Choose the first succeeding decoder, wrapping the result in a disjunction.

Choose the first succeeding decoder, wrapping the result in a disjunction.

Inherited from:
Decoder
Source:
Decoder.scala
final def emap[B](f: Option[A] => Either[String, B]): Decoder[B]

Create a new decoder that performs some operation on the result if this one succeeds.

Create a new decoder that performs some operation on the result if this one succeeds.

Value parameters:
f

a function returning either a value or an error message

Inherited from:
Decoder
Source:
Decoder.scala
final def emapTry[B](f: Option[A] => Try[B]): Decoder[B]

Create a new decoder that performs some operation on the result if this one succeeds.

Create a new decoder that performs some operation on the result if this one succeeds.

Value parameters:
f

a function returning either a value or an error message

Inherited from:
Decoder
Source:
Decoder.scala
final def ensure(errors: Option[A] => List[String]): Decoder[Option[A]]

Build a new instance that fails with one or more errors if the condition does not hold for the result.

Build a new instance that fails with one or more errors if the condition does not hold for the result.

If the result of the function applied to the decoded value is the empty list, the new decoder will succeed with that value.

Inherited from:
Decoder
Source:
Decoder.scala
final def ensure(pred: Option[A] => Boolean, message: => String): Decoder[Option[A]]

Build a new instance that fails if the condition does not hold for the result.

Build a new instance that fails if the condition does not hold for the result.

Note that in the case of chained calls to this method, only the first failure will be returned.

Inherited from:
Decoder
Source:
Decoder.scala
final def flatMap[B](f: Option[A] => Decoder[B]): Decoder[B]

Monadically bind a function over this Decoder.

Monadically bind a function over this Decoder.

Inherited from:
Decoder
Source:
Decoder.scala

Create a new instance that handles any of this instance's errors with the given function.

Create a new instance that handles any of this instance's errors with the given function.

Note that in the case of accumulating decoding, only the first error will be used in recovery.

Inherited from:
Decoder
Source:
Decoder.scala

Convert to a Kleisli arrow.

Convert to a Kleisli arrow.

Inherited from:
Decoder
Source:
Decoder.scala
final def map[B](f: Option[A] => B): Decoder[B]

Map a function over this Decoder.

Map a function over this Decoder.

Inherited from:
Decoder
Source:
Decoder.scala
final def or[AA >: Option[A]](d: => Decoder[AA]): Decoder[AA]

Choose the first succeeding decoder.

Choose the first succeeding decoder.

Inherited from:
Decoder
Source:
Decoder.scala
final def prepare(f: ACursor => ACursor): Decoder[Option[A]]

Create a new decoder that performs some operation on the incoming JSON before decoding.

Create a new decoder that performs some operation on the incoming JSON before decoding.

Inherited from:
Decoder
Source:
Decoder.scala
final def product[B](fb: Decoder[B]): Decoder[(Option[A], B)]

Run two decoders and return their results as a pair.

Run two decoders and return their results as a pair.

Inherited from:
Decoder
Source:
Decoder.scala
final def validate(pred: HCursor => Boolean, message: => String): Decoder[Option[A]]

Build a new instance that fails if the condition does not hold for the input.

Build a new instance that fails if the condition does not hold for the input.

Inherited from:
Decoder
Source:
Decoder.scala
final def validate(errors: HCursor => List[String]): Decoder[Option[A]]

Build a new instance that fails if the condition does not hold for the input.

Build a new instance that fails if the condition does not hold for the input.

Inherited from:
Decoder
Source:
Decoder.scala
final def withErrorMessage(message: String): Decoder[Option[A]]

Build a new instance with the specified error message.

Build a new instance with the specified error message.

Inherited from:
Decoder
Source:
Decoder.scala