AbstractJsonDecoder

zio.json.JsonDecoder.AbstractJsonDecoder
abstract class AbstractJsonDecoder[A] extends JsonDecoder[A]

Abstract class of the JsonDecoder trait to reduce class file size in subclasses.

Attributes

Source
JsonDecoder.scala
Graph
Supertypes
trait JsonDecoder[A]
class Object
trait Matchable
class Any

Members list

Value members

Inherited methods

final def *>[B](that: => JsonDecoder[B]): JsonDecoder[B]

An alias for JsonDecoder#zipRight.

An alias for JsonDecoder#zipRight.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def <*[B](that: => JsonDecoder[B]): JsonDecoder[A]

An alias for JsonDecoder#zipLeft.

An alias for JsonDecoder#zipLeft.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def <*>[B](that: => JsonDecoder[B]): JsonDecoder[(A, B)]

An alias for JsonDecoder#zip.

An alias for JsonDecoder#zip.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def <+>[B](that: => JsonDecoder[B]): JsonDecoder[Either[A, B]]

An alias for JsonDecoder#orElseEither.

An alias for JsonDecoder#orElseEither.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def <>[A1 >: A](that: => JsonDecoder[A1]): JsonDecoder[A1]

An alias for JsonDecoder#orElse.

An alias for JsonDecoder#orElse.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def both[B](that: => JsonDecoder[B]): JsonDecoder[(A, B)]

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def bothLeft[B](that: => JsonDecoder[B]): JsonDecoder[A]

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def bothRight[B](that: => JsonDecoder[B]): JsonDecoder[B]

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def bothWith[B, C](that: => JsonDecoder[B])(f: (A, B) => C): JsonDecoder[C]

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def decodeJson(bytes: Array[Byte]): Either[String, A]

Attempts to decode a value of type A from the specified UTF-8 encoded bytes, but may fail with a human-readable error message if the provided bytes do not encode a value of this type.

Attempts to decode a value of type A from the specified UTF-8 encoded bytes, but may fail with a human-readable error message if the provided bytes do not encode a value of this type.

The array is read in place, not copied.

Note: This method may not entirely consume the specified array.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def decodeJson(bytes: Chunk[Byte]): Either[String, A]

Attempts to decode a value of type A from the specified UTF-8 encoded bytes, but may fail with a human-readable error message if the provided bytes do not encode a value of this type.

Attempts to decode a value of type A from the specified UTF-8 encoded bytes, but may fail with a human-readable error message if the provided bytes do not encode a value of this type.

The bytes are decoded as they are parsed rather than copied into a String first, so this is the allocation friendly way to handle a payload that already arrived as bytes, e.g. an HTTP response body.

Note: This method may not entirely consume the specified chunk.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def decodeJson(str: CharSequence): Either[String, A]

Attempts to decode a value of type A from the specified CharSequence, but may fail with a human-readable error message if the provided text does not encode a value of this type.

Attempts to decode a value of type A from the specified CharSequence, but may fail with a human-readable error message if the provided text does not encode a value of this type.

Note: This method may not entirely consume the specified character sequence.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def decodeJsonPipeline(delimiter: JsonStreamDelimiter = ...): ZPipeline[Any, Throwable, Char, A]
final def decodeJsonStream[R](stream: ZStream[R, Throwable, Char]): ZIO[R, Throwable, A]

Attempts to decode a stream of characters into a single value of type A, but may fail with a human-readable exception if the stream does not encode a value of this type.

Attempts to decode a stream of characters into a single value of type A, but may fail with a human-readable exception if the stream does not encode a value of this type.

Note: This method may not consume the full string.

Attributes

See also
Inherited from:
JsonDecoderPlatformSpecific
Source
JsonDecoderPlatformSpecific.scala
final def decodeJsonStreamInput[R](stream: ZStream[R, Throwable, Byte], charset: Charset = ...): ZIO[R, Throwable, A]

Attempts to decode a stream of bytes using the user supplied Charset into a single value of type A, but may fail with a human-readable exception if the stream does not encode a value of this type.

Attempts to decode a stream of bytes using the user supplied Charset into a single value of type A, but may fail with a human-readable exception if the stream does not encode a value of this type.

Note: This method may not consume the full string.

Attributes

See also

decodeJsonStream For a Char stream variant

Inherited from:
JsonDecoderPlatformSpecific
Source
JsonDecoderPlatformSpecific.scala
final def fromJsonAST(json: Json): Either[String, A]

Decode a value from an already parsed Json AST.

Decode a value from an already parsed Json AST.

The default implementation encodes the Json to a byte stream and uses decode to parse that. Override to provide a more performant implementation.

Attributes

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

Returns a new codec whose decoded values will be mapped by the specified function.

Returns a new codec whose decoded values will be mapped by the specified function.

Attributes

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

Returns a new codec whose decoded values will be mapped by the specified function, which may itself decide to fail with some type of error.

Returns a new codec whose decoded values will be mapped by the specified function, which may itself decide to fail with some type of error.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def orElse[A1 >: A](that: => JsonDecoder[A1]): JsonDecoder[A1]

Returns a new codec that combines this codec and the specified codec using fallback semantics: such that if this codec fails, the specified codec will be tried instead. This method may be unsafe from a security perspective: it can use more memory than hand coded alternative and so lead to DOS.

Returns a new codec that combines this codec and the specified codec using fallback semantics: such that if this codec fails, the specified codec will be tried instead. This method may be unsafe from a security perspective: it can use more memory than hand coded alternative and so lead to DOS.

For example, in the case of an alternative between Int and Boolean, a hand coded alternative would look like:

val decoder: JsonDecoder[AnyVal] = JsonDecoder.peekChar[AnyVal] {
case 't' | 'f' => JsonDecoder[Boolean].widen
case c         => JsonDecoder[Int].widen
}

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def orElseEither[B](that: => JsonDecoder[B]): JsonDecoder[Either[A, B]]

Returns a new codec that combines this codec and the specified codec using fallback semantics: such that if this codec fails, the specified codec will be tried instead.

Returns a new codec that combines this codec and the specified codec using fallback semantics: such that if this codec fails, the specified codec will be tried instead.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
def unsafeFromJsonAST(trace: List[JsonError], json: Json): A

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def widen[B >: A]: JsonDecoder[B]

Returns this decoder but widened to the given super-type

Returns this decoder but widened to the given super-type

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def zip[B](that: => JsonDecoder[B]): JsonDecoder[(A, B)]

Returns a new codec that combines this codec and the specified codec into a single codec that decodes a tuple of the values decoded by the respective codecs.

Returns a new codec that combines this codec and the specified codec into a single codec that decodes a tuple of the values decoded by the respective codecs.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def zipLeft[B](that: => JsonDecoder[B]): JsonDecoder[A]

Zips two codecs, but discards the output on the right hand side.

Zips two codecs, but discards the output on the right hand side.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def zipRight[B](that: => JsonDecoder[B]): JsonDecoder[B]

Zips two codecs, but discards the output on the left hand side.

Zips two codecs, but discards the output on the left hand side.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala
final def zipWith[B, C](that: => JsonDecoder[B])(f: (A, B) => C): JsonDecoder[C]

Zips two codecs into one, transforming the outputs of zip codecs by the specified function.

Zips two codecs into one, transforming the outputs of zip codecs by the specified function.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala

Inherited and Abstract methods

def unsafeDecode(trace: List[JsonError], in: RetractReader): A

Low-level, unsafe method to decode a value or throw an exception. This method should not be called in application code, although it can be implemented for user-defined data structures.

Low-level, unsafe method to decode a value or throw an exception. This method should not be called in application code, although it can be implemented for user-defined data structures.

Attributes

Inherited from:
JsonDecoder
Source
JsonDecoder.scala