Abstract class for encoding and decoding values of type A to and from JSON formats. Encapsulates logic to map JSON representations into native type structures and vice versa, handling serialization and deserialization as per JSON encoding standards using UTF-8 character set.
This class requires an implementation for two core operations: decoding a value of type A from a JSON representation and encoding a value of type A into a JSON representation.
Attributes
- Companion
- object
- Source
- JsonCodec.scala
- Graph
-
- Supertypes
Members list
Value members
Abstract methods
Attempts to decode a value of type A from the specified JsonReader, but may fail with JsonCodecError 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 JsonCodecError error if the JSON input does not encode a value of this type.
Value parameters
- in
-
an instance of
JsonReaderthat provides access to the JSON input to parse a JSON value to value of typeA
Attributes
- Source
- JsonCodec.scala
Encodes the specified value using provided JsonWriter, but may fail with JsonCodecError if it cannot be encoded properly according to RFC-8259 requirements.
Encodes the specified value using provided JsonWriter, but may fail with JsonCodecError if it cannot be encoded properly according to RFC-8259 requirements.
Value parameters
- out
-
an instance of
JsonWriterthat provides access to JSON output to serialize the specified value as a JSON value - x
-
the value provided for serialization
Attributes
- Source
- JsonCodec.scala
Concrete methods
Decodes a value of type A from the given ByteBuffer. This method uses the default ReaderConfig to configure the decoding process. If decoding fails, a SchemaError is returned.
Decodes a value of type A from the given ByteBuffer. This method uses the default ReaderConfig to configure the decoding process. If decoding fails, a SchemaError is returned.
Value parameters
- input
-
the
ByteBuffercontaining the binary data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Definition Classes
- Source
- JsonCodec.scala
Decodes a value of type A from the given ByteBuffer using the specified ReaderConfig. If decoding fails, a SchemaError is returned.
Decodes a value of type A from the given ByteBuffer using the specified ReaderConfig. If decoding fails, a SchemaError is returned.
Value parameters
- config
-
the
ReaderConfiginstance used to configure the decoding process - input
-
the
ByteBuffercontaining the binary data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the given byte array using the default ReaderConfig. If decoding fails, a SchemaError is returned.
Decodes a value of type A from the given byte array using the default ReaderConfig. If decoding fails, a SchemaError is returned.
Value parameters
- input
-
the byte array containing the binary data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the provided byte array using the specified from and to slice indices. If decoding fails, an error of type SchemaError is returned.
Decodes a value of type A from the provided byte array using the specified from and to slice indices. If decoding fails, an error of type SchemaError is returned.
Value parameters
- from
-
the start index of the slice (inclusive)
- input
-
the byte array containing the binary data to be decoded
- to
-
the end index of the slice (exclusive)
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the provided byte array using the specified ReaderConfig. If decoding fails, an error of type SchemaError is returned.
Decodes a value of type A from the provided byte array using the specified ReaderConfig. If decoding fails, an error of type SchemaError is returned.
Value parameters
- config
-
the
ReaderConfiginstance used to configure the decoding process - input
-
the byte array containing the binary data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the provided byte array using the specified from and to slice indices and ReaderConfig. If decoding fails, an error of type SchemaError is returned.
Decodes a value of type A from the provided byte array using the specified from and to slice indices and ReaderConfig. If decoding fails, an error of type SchemaError is returned.
Value parameters
- config
-
the
ReaderConfiginstance used to configure the decoding process - from
-
the start index of the slice (inclusive)
- input
-
the byte array containing the binary data to be decoded
- to
-
the end index of the slice (exclusive)
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the provided InputStream using the default ReaderConfig. If decoding fails, a SchemaError is returned.
Decodes a value of type A from the provided InputStream using the default ReaderConfig. If decoding fails, a SchemaError is returned.
Value parameters
- input
-
the
InputStreamcontaining the binary data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the provided InputStream using the specified ReaderConfig. If decoding fails, a SchemaError is returned.
Decodes a value of type A from the provided InputStream using the specified ReaderConfig. If decoding fails, a SchemaError is returned.
Value parameters
- config
-
the
ReaderConfiginstance used to configure the decoding process - input
-
the
InputStreamcontaining the binary data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the given string using the default ReaderConfig. If decoding fails, a SchemaError is returned.
Decodes a value of type A from the given string using the default ReaderConfig. If decoding fails, a SchemaError is returned.
Value parameters
- input
-
the string containing the data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the provided string using the specified ReaderConfig. If decoding fails, an error of type SchemaError is returned.
Decodes a value of type A from the provided string using the specified ReaderConfig. If decoding fails, an error of type SchemaError is returned.
Value parameters
- config
-
the
ReaderConfiginstance used to configure the decoding process - input
-
a string containing the data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Decodes a value of type A from the given Json value. If decoding fails, a SchemaError is returned.
Decodes a value of type A from the given Json value. If decoding fails, a SchemaError is returned.
Value parameters
- input
-
the
Jsonvalue containing the data to be decoded
Attributes
- Returns
-
Eitherwhere theLeftcontains aSchemaErrorif decoding fails, or theRightcontains the successfully decoded value of typeA - Source
- JsonCodec.scala
Attempts to decode a value of type A from the specified JsonReader, but may fail with JsonCodecError 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 JsonCodecError error if the JSON input is not a key or does not encode a value of this type.
Value parameters
- in
-
an instance of
JsonReaderthat provides access to the JSON input to parse a JSON key to value of typeA
Attributes
- Source
- JsonCodec.scala
Attempts to decode a value of type A from the string representation.
Attempts to decode a value of type A from the string representation.
Attributes
- Source
- JsonCodec.scala
Decodes a Json value into a value of type A.
Encodes the specified value of type A into binary format and writes it to the provided ByteBuffer. This method uses the default WriterConfig for encoding configuration.
Encodes the specified value of type A into binary format and writes it to the provided ByteBuffer. This method uses the default WriterConfig for encoding configuration.
Value parameters
- output
-
the
ByteBufferwhere the encoded binary data is written - value
-
the value of type
Ato be serialized into binary format
Attributes
- Definition Classes
- Source
- JsonCodec.scala
Encodes the specified value of type A into binary format and writes it to the provided ByteBuffer using the specified WriterConfig for encoding configuration.
Encodes the specified value of type A into binary format and writes it to the provided ByteBuffer using the specified WriterConfig for encoding configuration.
Value parameters
- config
-
the
WriterConfiginstance used to configure the encoding process - output
-
the
ByteBufferwhere the encoded binary data is written - value
-
the value of type
Ato be serialized into binary format
Attributes
- Source
- JsonCodec.scala
Encodes the specified value of type A into a binary format using the default WriterConfig.
Encodes the specified value of type A into a binary format using the default WriterConfig.
Value parameters
- value
-
the value of type
Ato be serialized into binary format
Attributes
- Returns
-
an array of bytes representing the binary-encoded data
- Source
- JsonCodec.scala
Encodes the specified value of type A into a binary format using the provided WriterConfig.
Encodes the specified value of type A into a binary format using the provided WriterConfig.
Value parameters
- config
-
the
WriterConfiginstance used to configure the encoding process - value
-
the value of type
Ato be serialized into binary format
Attributes
- Returns
-
an array of bytes representing the binary-encoded data
- Source
- JsonCodec.scala
Encodes the specified value of type A into a binary format and writes it to the provided OutputStream. This method uses the default WriterConfig for encoding configuration.
Encodes the specified value of type A into a binary format and writes it to the provided OutputStream. This method uses the default WriterConfig for encoding configuration.
Value parameters
- output
-
the
OutputStreamwhere the encoded binary data is written - value
-
the value of type
Ato be serialized into binary format
Attributes
- Source
- JsonCodec.scala
Encodes the specified value of type A into a binary format and writes it to the given OutputStream using the provided WriterConfig for encoding configuration.
Encodes the specified value of type A into a binary format and writes it to the given OutputStream using the provided WriterConfig for encoding configuration.
Value parameters
- config
-
the
WriterConfiginstance used to configure the encoding process - output
-
the
OutputStreamwhere the encoded binary data is written - value
-
the value of type
Ato be serialized into binary format
Attributes
- Source
- JsonCodec.scala
Encodes the specified value using provided JsonWriter as a JSON key, but may fail with JsonCodecError 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 JsonCodecError if it cannot be encoded properly, according to RFC-8259 requirements.
Value parameters
- out
-
an instance of
JsonWriterthat provides access to JSON output to serialize the specified value as a JSON key - x
-
the value provided for serialization
Attributes
- Source
- JsonCodec.scala
Converts a value to its string representation for use as a JSON key.
Converts a value to its string representation for use as a JSON key.
Attributes
- Source
- JsonCodec.scala
Encodes the specified value of type A into a Json value.
Encodes the specified value of type A into a Json value.
Value parameters
- value
-
the value of type
Ato be serialized intoJsonvalue
Attributes
- Returns
-
a
Jsonvalue representing the encoded data - Source
- JsonCodec.scala
Encodes the specified value of type A into a string using the default WriterConfig.
Encodes the specified value of type A into a string using the default WriterConfig.
Value parameters
- value
-
the value of type
Ato be serialized into a string
Attributes
- Returns
-
a string representing the encoded data
- Source
- JsonCodec.scala
Encodes the specified value of type A into a string using the provided WriterConfig.
Encodes the specified value of type A into a string using the provided WriterConfig.
Value parameters
- config
-
the
WriterConfiginstance used to configure the encoding process - value
-
the value of type
Ato be serialized into a string
Attributes
- Returns
-
a string representing the encoded data
- Source
- JsonCodec.scala
Encodes a value of type A into a Json value.
Throws a JsonCodecError wrapping the given error and adding a span.
Throws a JsonCodecError wrapping the given error and adding a span.
Value parameters
- error
-
the error to wrap
- span
-
the span to add to the error
Attributes
- Throws
-
JsonCodecError
always
- Source
- JsonCodec.scala
Throws a JsonCodecError wrapping the given error and adding two spans.
Throws a JsonCodecError wrapping the given error and adding two spans.
Value parameters
- error
-
the error to wrap
- span1
-
the first span to add to the error
- span2
-
the second span to add to the error
Attributes
- Throws
-
JsonCodecError
always
- Source
- JsonCodec.scala
Throws a JsonCodecError wrapping the given error and adding spans.
Throws a JsonCodecError wrapping the given error and adding spans.
Value parameters
- error
-
the error to wrap
- spans
-
spans to add to the error
Attributes
- Throws
-
JsonCodecError
always
- Source
- JsonCodec.scala
Throws a JsonCodecError with the given error message.
Throws a JsonCodecError with the given error message.
Value parameters
- message
-
the error message
Attributes
- Throws
-
JsonCodecError
always
- Source
- JsonCodec.scala
Returns the JSON Schema describing values this codec encodes/decodes.
Returns the JSON Schema describing values this codec encodes/decodes.
Attributes
- Source
- JsonCodec.scala