b

    bod

    1 year ago
    Hello, World! I have a JSON API returning numbers, but apparently
    kotlin.Number
    is not Serializable. What's the easiest way to deal with this?
    j

    jw

    1 year ago
    Use Double. Number is kinda useless
    b

    bod

    1 year ago
    I guess I wanted to avoid Double because it's not precise... But actually all Longs can be represented as Doubles right? - no because Double and Long are both 64 bit
    j

    jw

    1 year ago
    It's not safe to return a number in JSON that won't fit in a Double anyway
    b

    bod

    1 year ago
    to be honest I wish the API in question would just distinguish integer and floating point fields 🙂. I ended up using Strings, with
    isLenient
    set to true, and decoding to the correct type on a higher layer (I guess I could have used a custom serializer but wanted to keep it simple.)