hey folks, after migrating to 1.0.0 version from 0...
# serialization
i
hey folks, after migrating to 1.0.0 version from 0.20.0, we noticed that API around
JsonLiteral
has changed. It's now
internal
and
body
is no longer field on class. We have some business logic that was relying on getting access to raw value
body
to understand what type is that value. Now looks like there is no way to say what type was the value when
JsonPrimitive
was created. The only hint
isString
flag that doesn't really helps. What was the main rationale of hiding
JsonLiteral
and
body
? Is there any plans to introduce more subclasses of
JsonPrimitive
like
JsonNumberPrimitive
,
JsonBooleanPrimitive
to better represent the primitive value type?
that should work for our case, but isn't better to have explicit type that tells what raw values is (int, long, float, double, boolean) than trying to convert string to long, double, boolean to find out the value type
v
What was the main rationale of hiding 
JsonLiteral
 and 
body
?
Because it was here by mistake (actually, as workaround for compiler bug, but nevertheless). Exposing
Any
type without clear restrictions and contracts it too permissive and potentially misleading. Could you please elaborate on why
isString
+
content
is not enough for your usage?
i
because
content: String
doesn't provide info if original value was either boolean or long or double
just to give you a little context, we serialize models into JsonElements and use it as intermediate representation. Then we traverse this tree and copy values over into special Map implementation that supports only this special map, list, and primitives.
so before we were checking the type of Any to proper call API: putLong, putDouble, putBoolean etc.