How can I handle extra fields when deserialising? ...
# serialization
s
How can I handle extra fields when deserialising? For example, I have -
class Foo(val bar: String)
in. json I have
{ bar: 'asd', foobar: 'jkl', fb1: 'abc'}
I want to deserialise the above json into class Foo, but also be. able to access
foobar & fb1
, somehow. without having to add those fields in class Foo specifically. What I am looking for is something like
extraFields
map
n
you probably want to serialize your json in a
JsonObject
for raw access and then deserialize the object into your class with
ignoreUnknownKeys
set on
Json