Currently Map<string, V> is serialized as a plain JSON object. However, Map<K, V> where K is a single-case union containing a string is still treated like an arbitrary key type, and serialized as an array of [key, value] pairs. It should be serialized as an object instead.
type UserId = UserId of string
JsonSerializer.Serialize(Map [(UserId "Jane", 123); (UserId "John", 456)], options)
// Currently: [["Jane",123],["John",456]]
// Expected: {"Jane":123,"John":456}
Currently
Map<string, V>
is serialized as a plain JSON object. However,Map<K, V>
whereK
is a single-case union containing a string is still treated like an arbitrary key type, and serialized as an array of[key, value]
pairs. It should be serialized as an object instead.