Thread
#serialization
    s

    Sam

    3 years ago
    I'm consuming an api that uses an empty string for a null but sends an object when the key is not null like so:
    "mods":{"mod1":""}
    "mods":{"mod1":{"comp":">=","point":3}}
    Is there a way to construct a class or annotate the property to deal with this?
    Dominaezzz

    Dominaezzz

    3 years ago
    I was battling with this yesterday. Basically inferring type from the payload is not possible.
    Nvm, I'm wrong.
    s

    Sam

    3 years ago
    That’s the route I ended up going down. It wasn’t too painful. I made the custom serializer on the object containing the switchable key and returned a default empty mod1 object if the value was a json literal type.