Comments (6)
I think the best would be to do what you propose by default (ie Some
stored as just the value; None
is already stored as null
), with an opt-out flag for people who need to distinguish between None
and Some null
(or Some None
).
from fsharp.systemtextjson.
I would propose adding another option called BareFieldlessTags
This will encode cases without any fields as just the case name. For example:
ExternalTag ||| BareFieldlessTags
:
{ "Foo": [ 123, "hello" ] }
"Bar"
ExternalTag ||| NamedFields ||| BareFieldlessTags
:
{ "Foo": { "x": 123, "y": "hello" } }
"Bar"
The motivation is when serializing Unions that represent a series of simple codes.
from fsharp.systemtextjson.
That's a great idea!
from fsharp.systemtextjson.
That's great to have a choice. But I don't need it for Options. its a special case from my sight. Should be just serialized to value inside of Some
and None
to null
from fsharp.systemtextjson.
Agree, though that's their fault if they model option of option or list of option, etc. :)
from fsharp.systemtextjson.
Closing as this was released in v0.4 (the union issue is handled in #16).
from fsharp.systemtextjson.
Related Issues (20)
- Disallow null if not option-wrapped everywhere, not just for record fields HOT 6
- Allow using single-case unions as dictionary keys HOT 1
- Allow handling arbitrary Map keys as JSON object properties HOT 1
- [StructuralComparison] for `Skippable` HOT 3
- Record deserialization throws NRE if ignore null values is on
- Support Tuples HOT 1
- WithUnwrapOption(false) still serializes None as null HOT 5
- Regression in 1.2: NullReferenceException when serializing null record field HOT 3
- WithSkippableOptionFields fails roundtrip when option inside union
- Deserialize null or missing fields as None? HOT 6
- NotSupported exception when dictionary key is union (DU)
- Incorrect missing field name - seems to pick name of first null field, even if field is optional
- Allow overriding generic types
- Allow overriding property and union case attributes in options
- Can't parse Option<'T> from a json field that's either missing or null HOT 3
- Untagged Attribute and options configurations don't seem to be working HOT 2
- Custom serializer/`JsonConverter` for a record HOT 1
- Allowing null fields example from the docs is not working HOT 2
- Do not use FSharp.SystemTextJson on types that do not have the [<JsonFSharpConverter>] attribute HOT 1
- How to upgrade from 0.17.4 for single case unions and skippable fields? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsharp.systemtextjson.