a) TypeSafeEnums e.g. type ProductId = ProductA | ProductB (where you just want "ProductA", as the TypeSafeEnumconverter would do if applied explicitly)
b) Unions that should render as a JSON object (record)
type UnionThatShouldBeAnObject =
| SimpleProduct of master: ProductId
| PairedProduct of {| primary: ProductId; backup: ProductId |}
will render as { "Case": "PairedProduct", "primary": "ProductA", "backup": "ProductA"} or { "Case": "PairedProduct", "master": "ProductA"}, as it would if you applied the UnionConverter explicitly
Backport the
autoTypeSafeEnumToJsonString
andautoUnionToJsonObject
options to avoid the nasty surprised the default impl causes when (not if!) people fall into the default rendering trap for things lke:a)
TypeSafeEnum
s e.g.type ProductId = ProductA | ProductB
(where you just want"ProductA"
, as theTypeSafeEnumconverter
would do if applied explicitly) b) Unions that should render as a JSON object (record)will render as
{ "Case": "PairedProduct", "primary": "ProductA", "backup": "ProductA"}
or{ "Case": "PairedProduct", "master": "ProductA"}
, as it would if you applied the UnionConverter explicitly96 is a very important related safety feature too
i.e.prevent:
and default to
related: https://github.com/JamesNK/Newtonsoft.Json/issues/1662#issuecomment-1646777848