Add implicit com.rojoma.json.v3.codec.JsonEncode and com.rojoma.json.v3.codec.JsonDecode instances to the annotated class.
Add an implicit com.rojoma.json.v3.codec.JsonDecode instance to the annotated class.
Add an implicit com.rojoma.json.v3.codec.JsonDecode instance to the annotated class.
when using this macro, annotated case classes must specify context bounds explicitly rather than using ":" syntax, due to https://github.com/scala/bug/issues/10589
Add an implicit com.rojoma.json.v3.codec.JsonEncode instance to the annotated class.
Add an implicit com.rojoma.json.v3.codec.JsonEncode instance to the annotated class.
when using this macro, annotated case classes must specify context bounds explicitly rather than using ":" syntax, due to https://github.com/scala/bug/issues/10589
Specifies that the base codec should add (and possibly remove) an extra field to the objects generated by the subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes (and they must be objects).
Specifies that the base codec should add (and possibly remove) an extra field to the objects generated by the subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes (and they must be objects).
abstract class Base case class SubclassA(name: String) extends Base case class SubclassB(x: Int, y: Int) extends Base implicit val aCodec = SimpleJsonCodecBuilder[SubclassA].build("name", _.name) implicit val bCodec = SimpleJsonCodecBuilder[SubclassB].build("x", _.x, "y", _.y) val baseCodec = SimpleHierarchyCodecBuilder[Base](InternalTag("type")). branch[SubclassA]("a"). branch[SubclassB]("b"). build println(baseCodec.encode(SubclassA("John"))) // { "type" : "a", "name" : "John" } println(baseCodec.encode(SubclassB(1, 2))) // { "type" : "b", "x" : 1, "y" : 2 }
Specifies that the base codec should not affect the subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes at all and that the decoder should simply try each codec in turn, in the order they were provided to the builder, until it finds one that succeeds.
Specifies that the base codec should not affect the subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes at all and that the decoder should simply try each codec in turn, in the order they were provided to the builder, until it finds one that succeeds.
abstract class Base case class SubclassA(name: String) extends Base case class SubclassB(x: Int, y: Int) extends Base implicit val aCodec = SimpleJsonCodecBuilder[SubclassA].build("name", _.name) implicit val bCodec = SimpleJsonCodecBuilder[SubclassB].build("x", _.x, "y", _.y) val baseCodec = SimpleHierarchyCodecBuilder[Base](NoTag). branch[SubclassA]. branch[SubclassB]. build println(baseCodec.encode(SubclassA("John"))) // { "name" : "John" } println(baseCodec.encode(SubclassB(1, 2))) // { "x" : 1, "y" : 2 }
Specifies that the base codec should wrap the value generated by subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes in another object containing two fields; one for the type-tag and one for the actual value.
Specifies that the base codec should wrap the value generated by subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes in another object containing two fields; one for the type-tag and one for the actual value.
abstract class Base case class SubclassA(name: String) extends Base case class SubclassB(x: Int, y: Int) extends Base implicit val aCodec = SimpleJsonCodecBuilder[SubclassA].build("name", _.name) implicit val bCodec = SimpleJsonCodecBuilder[SubclassB].build("x", _.x, "y", _.y) val baseCodec = SimpleHierarchyCodecBuilder[Base](TagAndValue("type", "value")). branch[SubclassA]("a"). branch[SubclassB]("b"). build println(baseCodec.encode(SubclassA("John"))) // { "type" : "a", "value" : { "name" : "John" } } println(baseCodec.encode(SubclassB(1, 2))) // { "type" : "b", "value" : { "x" : 1, "y" : 2 } }
Specifies the mechanism for distinguishing among subclasses in a hierarchy with a tag.
Specifies the mechanism for distinguishing among subclasses in a hierarchy with a tag.
A container for a slice of an Array[Char]
which promises to allow only read-only
access to that array.
A container for a slice of an Array[Char]
which promises to allow only read-only
access to that array. Note it does not itself copy the array, so if there is another
reference the data can be mutated by other operations.
Converting iterators-of-jsonables to iterators that represent
JArray
s, without holding onto the contents of the iterator.
Helper for reading lazily reading objects out of a source of
JsonEvent
s representing a JSON array.
Helper for reading lazily reading objects out of a source of
JsonEvent
s representing a JSON array. Calling hasNext
can throw
any JsonLexException
. Calling next()
can throw any JSON lex or parse
exception, or ElementDecodeException
if the data in the array cannot be
decoded as a T
at that point. In the latter case, the iterator is still
valid and positioned as if the decode had succeeded so it can continue to
be used.
An iterator of T
s
JsonBadParse
if alreadyInArray
is false and the first event is not a StartOfArrayEvent
JsonLexException
if alreadyInArray
is false and a lexing exception or EOF occurs.
Specifies that the base codec should wrap the value generated by subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes in another object containing a single field, which is the tag for that subclass.
Specifies that the base codec should wrap the value generated by subclasses' com.rojoma.json.v3.codec.JsonEncodes and com.rojoma.json.v3.codec.JsonDecodes in another object containing a single field, which is the tag for that subclass.
abstract class Base case class SubclassA(name: String) extends Base case class SubclassB(x: Int, y: Int) extends Base implicit val aCodec = SimpleJsonCodecBuilder[SubclassA].build("name", _.name) implicit val bCodec = SimpleJsonCodecBuilder[SubclassB].build("x", _.x, "y", _.y) val baseCodec = SimpleHierarchyCodecBuilder[Base](TagToValue). branch[SubclassA]("a"). branch[SubclassB]("b"). build println(baseCodec.encode(SubclassA("John"))) // { "a" : { "name" : "John" } } println(baseCodec.encode(SubclassB(1, 2))) // { "b" : { "x" : 1, "y" : 2 } }
Creates a combined com.rojoma.json.v3.codec.JsonEncode and com.rojoma.json.v3.codec.JsonDecode for a simple wrapper type.
Creates a combined com.rojoma.json.v3.codec.JsonEncode
and com.rojoma.json.v3.codec.JsonDecode for a simple wrapper type.
The wrap
function may throw IllegalArgumentException
; this
is translated to a com.rojoma.json.v3.codec.DecodeError.InvalidValue.
Creates a com.rojoma.json.v3.codec.JsonDecode for a simple wrapper type.
Creates a com.rojoma.json.v3.codec.JsonDecode for a simple wrapper type.
The wrap
function may throw IllegalArgumentException
; this
is translated to a com.rojoma.json.v3.codec.DecodeError.InvalidValue.
Creates a com.rojoma.json.v3.codec.JsonEncode for a simple wrapper type.
Add implicit com.rojoma.json.v3.codec.JsonEncode and com.rojoma.json.v3.codec.JsonDecode instances to the annotated class.
when using this macro, annotated case classes must specify context bounds explicitly rather than using ":" syntax, due to https://github.com/scala/bug/issues/10589