Closed gusty closed 4 years ago
I think it would be a good change since the (string * JsonValue) []
is a more raw representation of the json format. Any deserialization into values will use just one of the values if there they have the same key.
The concern about multiple keys is also there.
At first sight I thought that had been one of the reasons for (string * JsonValue) []
, since Json in theory allows multiple keys, but even in that case as you said, it would at some point use a dictionary and would use just one of the keys.
If we really want to support multiple keys we should change drastically the design and use a MultiMap, in all 4 implementations, but still I'm not sure all 4 libs (as standalone) support multiple keys.
Closed by #82
Until now, Fleece for FSharp.Data defined JsonObject as a
(string * JsonValue) []
.This implies that depending on how do we interpret it, could be serialized either as
JObject
orJArray
which might result in problems.The idea is to use a type alias to a type that already serialize to
JObject
.I propose to use
Map<string,JsonValue>
.We could consider
IReadOnlyDictionary<string,JsonValue>
, which is used internally and we don't have an overload for it, but note that being an interface, we need to assess first that no undesired subsumption would happen in the overload resolution.Note that this might break things in projects using
FSharp.Data
, but forSystem.Text.Json
there won't be problems as long as this change is included in its first release.Finally, I don't know why the type alias to
(string * JsonValue) []
was choosen, not sure if @eulerfx can remember the reason and give some feedback.