Comments (4)
Hey @bartelink, apologies for the delay. This behavior makes sense and I'll update the PR.
from fscodec.
Thanks for logging an issue, and taking the time to add a PR too. In this instance I'm not sure the best answer is to actually change the behavior of FsCodec; I'll try to explain why...
String can legitimately have null
as a value. You have two choices:
- use
string option
to represent thenull
- apply json.net rules to outlaw null for that field or in general
- the Settings.Create has an overload for allowNulls which may or may not help
- json.net has attributes to change the default for a type to outlaw nulls, which you can then provide exceptions to by tagging individual properties/fields
See https://github.com/jet/equinox/blob/master/src/Equinox.CosmosStore/CosmosStore.fs#L22 (I leave it in default mode but outlaw nulls that I am not handling intentionally)
Would appreciate if the PR could add a paragraph to the README to explain this technique / convention when using json.net (having a characterization test or two illustrating it too would be helpful too but from my perspective those tests should not be failing - i.e. this is by design, unless I'm really missing something)
from fscodec.
It should also be mentioned that FsCodec.SystemTextJson should be providing an analogous mechanism. I'm not sure how easy/possible that is, but in general FsCodec is seeking to provide a pragmatic middle way of using NSJ or STJ in F# without completely changing what one might expect to happen when using json.net in order to provide an F# only experience - i.e. the aim is to provide helpers to smooth the way for using reflection based serialization in a way that would not surprise people coming from a C# background and/or in mixed C#+F# codebases.
I hope this explains the intent a little better than the above
from fscodec.
@kevingentile Does this make sense to you? Can you please close the issue and PR if so and/or provide a PR that updates the README to better express the design in a manner that explains this in a way which would have saved you the confusion?
from fscodec.
Related Issues (20)
- feat(UnionConverter): Support upconvert from string to nullary case
- chore: Add Package Validation
- Support System.Text.Json.Utf8JsonReader HOT 3
- V 1.0.0 checklist HOT 1
- Rename IUnionEncoder to IEventCodec
- Question: nested DU support? HOT 5
- Add IEventData.EventId
- Default to preventing over-escaping in FsCodec.SystemTextJson standard profile HOT 2
- feat: Contract types validation HOT 2
- Request for Codec.Create with Format of byte [] HOT 2
- global.jsons target a specific .net core 3.1 SDK version, should target .net core 3.1 in general HOT 1
- Multiple hypens in stream names HOT 2
- V3 checklist
- Relaxing `requireRecordFields = true` HOT 17
- Feature: Allow independent control of auto Union vs Typesafe Enum conversion in UnionOrTypeSafeEnumConverterFactory HOT 9
- Feature: EncodingType HOT 1
- feat(NewtonsoftJson): Unions backstop
- feat(NewtonsoftJson): Upconvert from Case that should be a string HOT 3
- feat(NewtonsoftJson): backport Serdes ctor auto* options from STJ side of the house
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 fscodec.