fsprojects / FSharp.Json

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

Q: how do you decode dictionary keys that vary? #60

Open sanikolov opened 2 years ago

sanikolov commented 2 years ago

Consider a web request for 1 or more of 3 keys that are known ahead of time - foo, bar, cow.

curl "http://host/getme?key=foo,cow"
{"foo": "val1", "cow": "val2"}   # bar is missing because we didn't ask for it

A typical record type definition won't work because we may or may not get the all the keys in the json reply. I looked in the docs and the closest match were union (sum) types but are they able to solve this? Not seeing how.