Return an instance for a given type.
Create a decoder that always returns a single value, useful with some flatMap
situations.
Decode a JSON value into a scala.math.BigDecimal.
Decode a JSON value into a scala.math.BigDecimal.
Note that decoding will fail on some very large values that could in principle be represented
as BigDecimal
s (specifically if the scale
is out of the range of scala.Int
when the
unscaledValue
is adjusted to have no trailing zeros). These large values can, however, be
round-tripped through JsonNumber
, so you may wish to use decodeJsonNumber in these cases.
Also note that because scala.scalajs.js.JSON
parses JSON numbers into a floating point
representation, decoding a JSON number into a BigDecimal
on Scala.js may lose precision.
Decode a JSON value into a scala.math.BigInt.
Decode a JSON value into a scala.math.BigInt.
Note that decoding will fail if the number has a large number of digits (the limit is currently
1 << 18
, or around a quarter million). Larger numbers can be decoded by mapping over a
scala.math.BigDecimal, but be aware that the conversion to the integral form can be
computationally expensive.
Decode a JSON value into a scala.Byte.
Decode a JSON value into a scala.Byte.
See decodeLong for discussion of the approach taken for integral decoding.
Decode a JSON value into a scala.Double.
Decode a JSON value into a scala.Double.
Unlike the integral decoders provided here, this decoder will accept values that are too large
to be represented and will return them as PositiveInfinity
or NegativeInfinity
, and it may
lose precision.
Decode a JSON value into a scala.Float.
Decode a JSON value into a scala.Float.
See decodeDouble for discussion of the approach taken for floating-point decoding.
Decode a JSON value into a scala.Int.
Decode a JSON value into a scala.Int.
See decodeLong for discussion of the approach taken for integral decoding.
Decode a JSON value into a scala.Long.
Decode a JSON value into a scala.Long.
Decoding will fail if the value doesn't represent a whole number within the range of the target
type (although it can have a decimal part: e.g. 10.0
will be successfully decoded, but
10.01
will not). If the value is a JSON string, the decoder will attempt to parse it as a
number.
The resulting instance will not be serializable (in the java.io.Serializable
sense)
unless the provided scala.collection.generic.CanBuildFrom is serializable.
The resulting instance will not be serializable (in the java.io.Serializable
sense)
unless the provided scala.collection.generic.CanBuildFrom is serializable.
Decode a JSON value into a scala.Short.
Decode a JSON value into a scala.Short.
See decodeLong for discussion of the approach taken for integral decoding.
The resulting instance will not be serializable (in the java.io.Serializable
sense)
unless the provided scala.collection.generic.CanBuildFrom is serializable.
object WeekDay extends Enumeration { ... } implicit val weekDayDecoder = Decoder.enumDecoder(WeekDay)
Construct an instance that always fails with the given DecodingFailure.
Construct an instance that always fails with the given error message.
Construct an instance from a cats.data.StateT value.
Construct an instance from a function.
This is for easier interop with code that already returns scala.util.Try.
This is for easier interop with code that already returns scala.util.Try. You should
prefer instance
for any new code.
Helper methods for working with cats.data.StateT values that transform the ACursor.
Construct an instance from a function that may reattempt on failure.
Instance creation methods for disjunction-like types. Note that these instances are not implicit, since they require non-obvious decisions about the names of the discriminators. If you want instances for these types you can include the following import in your program:
import io.circe.disjunctionCodecs._
Utilities and instances for Decoder.