s

    Sourabh Rawat

    1 year ago
    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
    Nikky

    Nikky

    1 year ago
    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