This is used by the case class macros to buffer data for polymorphic types
when the discriminator is not the first element, e.g. {"foo": 1, "$type": "discriminator"}.
It is important that all types be immutable.
May be superior to use in client code as well under some circumstances, e.g.,
when representing data from and to non-JSON types. For example, when piped through a
Value, java.time.Instant will come out the other side as visitString rather than
visitTimestamp, leading to potentially wasteful parsing/formatting. Other advantages
are: immutable, more efficient number representation (BigDecimal has a lot of performance
overhead when applied to smaller numeric types), and direct representation of binary
and extension types (without assumed JSON byte array encoding).
Most Visitor methods are represented by their own case classes. Exceptions are:
- Float64String and UInt64 - along with Float64StringParts, represented as Num
- Int32 - along with Int64, represented as NumLong
- Float32 - along with Float64, represented as NumDouble
- Char - along with String, represented as Str
Therefore, when transforming from a BufferedValue, the specific visit methods for these
will never be called (e.g., for integers, visitInt32 will never be called, only visitInt64).
A version of com.rallyhealth.weejson.v1.Value used to buffer data in raw form.
This is used by the case class macros to buffer data for polymorphic types when the discriminator is not the first element, e.g.
{"foo": 1, "$type": "discriminator"}
. It is important that all types be immutable.May be superior to use in client code as well under some circumstances, e.g., when representing data from and to non-JSON types. For example, when piped through a
Value
,java.time.Instant
will come out the other side asvisitString
rather thanvisitTimestamp
, leading to potentially wasteful parsing/formatting. Other advantages are: immutable, more efficient number representation (BigDecimal has a lot of performance overhead when applied to smaller numeric types), and direct representation of binary and extension types (without assumed JSON byte array encoding).Most Visitor methods are represented by their own case classes. Exceptions are: - Float64String and UInt64 - along with Float64StringParts, represented as Num - Int32 - along with Int64, represented as NumLong - Float32 - along with Float64, represented as NumDouble - Char - along with String, represented as Str
Therefore, when transforming from a BufferedValue, the specific visit methods for these will never be called (e.g., for integers, visitInt32 will never be called, only visitInt64).