Closed Tarmil closed 1 year ago
It's actually not really possible to choose the format based on whether the key type's converter supports {Read|Write}AsPropertyName. There isn't a flag that tells whether they're supported; just these two methods, that will either succeed or fail when called.
So a better option would be to follow what @cmeeren suggests in #152 and allow choosing the format in JsonFSharpOptions.
Since .NET 6, the handling of dictionary keys can be customized using
JsonConverter.Write/ReadAsPropertyName
. Our Map converter should try use these methods in the same way, and only fall back to array-of-pairs in JSON if it can't.