r

    rocketraman

    1 year ago
    Is the JSON serializer deterministic? i.e. if two input data classes are equal, will it always produce the same output, regardless of where and when? I think we can assume the same version of kotlinx-serialization is always used.
    Dominaezzz

    Dominaezzz

    1 year ago
    The same compiled binary, yes. Stability issue would come from the Kotlin compiler as it does not guarantee field order iirc.
    r

    rocketraman

    1 year ago
    Probably safest to apply a canonicalization to it. https://github.com/erdtman/java-json-canonicalization seems like it will work.
    elizarov

    elizarov

    1 year ago
    Kotlin serialization guarantees the same field order as in the program. The differences may come only between different versions of libs, if serialization format has a leeway in how things can be encoded.
    However, the underlying data may be non-deterministic. E.g. a
    HashMap
    has no defined order of entries.