JCodec

trait JCodec[A] extends JsonCodec[A]

Construct that expresses the ability to decode an http message, the metadata of which will have already been decoded and staged in a Map[String, Any] indexed by field.

On the encoding side, the fields that should be stored in metadata are eluded.

Companion:
object
trait JsonCodec[A]
trait JsonKeyCodec[A]
trait JsonValueCodec[A]
trait Serializable
class Object
trait Matchable
class Any

Value members

Abstract methods

def decodeValue(cursor: Cursor, in: JsonReader): A

Concrete methods

def biject[B](to: A => B, from: B => A): JCodec[B]
def decodeMessage(in: JsonReader): Map[String, Any] => A
final override def decodeValue(in: JsonReader, default: A): A

Attempts to decode a value of type A from the specified JsonReader, but may fail with JsonReaderException error if the JSON input does not encode a value of this type.

Attempts to decode a value of type A from the specified JsonReader, but may fail with JsonReaderException error if the JSON input does not encode a value of this type.

Value parameters:
default

the placeholder value provided to initialize some possible local variables

in

an instance of JsonReader which provide an access to the JSON input to parse a JSON value to value of type A

Definition Classes
JsonValueCodec

States whether this codec expects data from the body of an http request (as opposed to from headers, query params, etc). Used to prevent parsing altogether when not required.

States whether this codec expects data from the body of an http request (as opposed to from headers, query params, etc). Used to prevent parsing altogether when not required.

final override def nullValue: A

Returns some placeholder value that will be used by the high level code that generates codec instances to initialize local variables for parsed field values which have a codec that was injected using implicit val.

Returns some placeholder value that will be used by the high level code that generates codec instances to initialize local variables for parsed field values which have a codec that was injected using implicit val.

See the jsoniter-scala-macros sub-project code and its tests for usages of .nullValue calls.

Definition Classes
JsonValueCodec
def widen[B >: A]: JCodec[B]

Inherited methods

def decodeKey(in: JsonReader): A

Attempts to decode a value of type A from the specified JsonReader, but may fail with JsonReaderException error if the JSON input is not a key or does not encode a value of this type.

Attempts to decode a value of type A from the specified JsonReader, but may fail with JsonReaderException error if the JSON input is not a key or does not encode a value of this type.

Value parameters:
in

an instance of JsonReader which provide an access to the JSON input to parse a JSON key to value of type A

Inherited from:
JsonKeyCodec
def encodeKey(x: A, out: JsonWriter): Unit

Encodes the specified value using provided JsonWriter as a JSON key, but may fail with JsonWriterException if it cannot be encoded properly according to RFC-8259 requirements.

Encodes the specified value using provided JsonWriter as a JSON key, but may fail with JsonWriterException if it cannot be encoded properly according to RFC-8259 requirements.

Value parameters:
out

an instance of JsonWriter which provides access to JSON output to serialize the specified value as a JSON key

x

the value provided for serialization

Inherited from:
JsonKeyCodec
def encodeValue(x: A, out: JsonWriter): Unit

Encodes the specified value using provided JsonWriter, but may fail with JsonWriterException if it cannot be encoded properly according to RFC-8259 requirements.

Encodes the specified value using provided JsonWriter, but may fail with JsonWriterException if it cannot be encoded properly according to RFC-8259 requirements.

Value parameters:
out

an instance of JsonWriter which provides access to JSON output to serialize the specified value as a JSON value

x

the value provided for serialization

Inherited from:
JsonValueCodec

Concrete fields