eed3si9n / sjson-new

a typeclass based JSON codec that's backend independent
Apache License 2.0
36 stars 19 forks source link

LList binding depends on the insertion ordering of fields #36

Closed eed3si9n closed 7 years ago

eed3si9n commented 7 years ago

Although I personally think AST should be able to roundtrip from source, we can't assume insertion order to be preserved by various AST implementations. As such LList encoding should probably use JArray.

dwijnand commented 7 years ago

Wouldn't this mean that case classes are encoded as an array of name/value pairs?

Ie a JSON array of JSON objects?

eed3si9n commented 7 years ago

I thought of a workaround that's not so ugly. Just persist the field order as "$fields".

dwijnand commented 7 years ago

Just for clarity you mean LList would serialise a class to a JSON object, with an additional synthetic "$fields" field, which is a JSON array of the field names (strings), in the order the fields were defined?

eed3si9n commented 7 years ago

Yea, that can get natural looking JObject without relying on the insertion order.