I have some multiplatform code that generates JSON. However, sometimes, the JSON is slightly different in ways that doesn't matter (e.g. one system writes
1
and another writes
1.0
). Could KotlinX.Serialization be used to deserialize multiple JSON representations and tell me if they are equal or not?
e
ephemient
04/03/2025, 11:49 AM
whenever they're equivalent depends on how they're used
ephemient
04/03/2025, 11:50 AM
if you parse those into JsonElements, they'll be unequal
c
CLOVIS
04/03/2025, 1:21 PM
Is there a way to parse these such that they are equal?
s
Sebastian Schuberth
04/03/2025, 1:27 PM
Sure, you could parse them as doubles, for example. Or even use a custom deserializer with logic to normalize such entries.