fsprojects / FSharp.Json

F# JSON Reflection based serialization library
Apache License 2.0
222 stars 26 forks source link

Support for IReadOnlyDictionary<K,V>? #44

Open smoothdeveloper opened 3 years ago

smoothdeveloper commented 3 years ago

I wonder if it could be supported by the libray, it seems to fail with what I hoped to serialize:

#r "nuget: FSharp.Json"
readOnlyDict [1,2;3,4] |> FSharp.Json.Json.serialize
FSharp.Json.JsonSerializationError: Failed to serialize, must be one of following types: record, map, array, list, tuple, union. Type is: Dictionary`2.
   at FSharp.Json.Core.failSerialization[a](String message)
   at FSharp.Json.Core.serialize(JsonConfig config, Type t, Object value)
   at FSharp.Json.Json.serializeEx(JsonConfig config, Object theobj)
   at FSharp.Json.Json.serialize(Object theobj)
   at <StartupCode$FSI_0012>.$FSI_0012.main@()