feat(NewtonsoftJson): backport Serdes ctor auto* options from STJ side of the house
- Dominant language
- F#
- Stars
- 82
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Backport [the `autoTypeSafeEnumToJsonString` and `autoUnionToJsonObject` options](https://github.com/jet/FsCodec#fscodecsystemtextjsonoptions) 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 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
#96 is a very important related safety feature too
i.e.prevent:
```
"items": [
{
"serviceId": "5c8795be52e34e82883d61babed19513",
"serviceKind": {
"Case": "ProductA"
}
},
{
"serviceId": "8a55ebbf0d404485b50da95bdb53f7b3",
"serviceKind": {
"Case": "ProductB"
}
}
]
},
```
and default to
```
"items": [
{
"serviceId": "5c8795be52e34e82883d61babed19513",
"serviceKind": "ProductB"
},
{
"serviceId": "8a55ebbf0d404485b50da95bdb53f7b3",
"serviceKind": "ProductA"
}
]
```
related: https://github.com/JamesNK/Newtonsoft.Json/issues/1662#issuecomment-1646777848
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.