Hey folks :wave: while deserializing (implementin...
# serialization
n
Hey folks đź‘‹ while deserializing (implementing
KSerializer.deserialize
), is there a way to get access to the “raw” value of a primitive? As a string, for example. Since JSON numbers don’t have to be floating point numbers (by the standard https://www.json.org/json-en.html, although some implementation do assume that they are all double, unfortunately), I need a way to read fractional numbers from JSON without compromising their precision (to convert them to some decimal type, for example), none of the existing
Decoder
can do that it seems. Am I missing something? One option would be to write such values as strings server-side, but 1) it’s not always feasible to change existing endpoints that are just fine 2) one doesn’t always control the API. UPD found an issue, apparently it’s not possible atm: https://github.com/Kotlin/kotlinx.serialization/issues/1405
same question goes for serialization, is there a way to write arbitrary bytes as a JSON value?