Thread
#serialization
    pajatopmr

    pajatopmr

    1 year ago
    As I understand the JSON spec, there is no order dependence on fields on a JSON object:
    {"foo":"fooValue","fee":"feeValue"}
    and `{"fee":"feeValue","foo":"fooValue"}`should deserialize to the same object. But this is apparently not the case with KXS. Is there some fine print that says JSON implementors can do pretty much what they want or is this a bug of some sort? My assumption is the former so that means transforming incoming JSON to a correct order. Any chance I have this assumption wrong?
    v

    Vampire

    1 year ago
    Order shouldn't be important and KXS should handle it well afair.
    Yes, it does, why do you think it does not?
    h

    HankG

    1 year ago
    Yeah I just did a simple test, that is confirming order doesn't matter in this (as expected)
    @Serializable
    data class TestData(val fee:String, val foo:String)
    ...
    
    val json1 = "{\"fee\":\"feeValue\",\"foo\":\"fooValue\"}"
    val json2 = "{\"foo\":\"fooValue\",\"fee\":\"feeValue\"}"
    val obj1 = decodeFromString(TestData.serializer(), json1)
    val obj2 = decodeFromString(TestData.serializer(), json2)
    println(obj1)
    println(obj2)
    println(obj1 == obj2)
    pajatopmr

    pajatopmr

    1 year ago
    Good to know. I’ll drill into my test case and figure out what is amiss. Thanks for the feedback.
    v

    Vampire

    1 year ago
    Maybe you did not have a data class and thus no equals implementation?
    pajatopmr

    pajatopmr

    1 year ago
    Yes, I did not have a data class. I will try that.
    Turns out that I had another problem entirely (with encoding, not decoding). When I fixed that I discovered that a data class was not required, fwiw.