eed3si9n / sjson-new

a typeclass based JSON codec that's backend independent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LList binding depends on the insertion ordering of fields

eed3si9n opened this issue · comments

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.

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

Ie a JSON array of JSON objects?

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

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?

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