Giter Club home page Giter Club logo

Comments (6)

Tarmil avatar Tarmil commented on August 18, 2024 3

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.

jbeeko avatar jbeeko commented on August 18, 2024 2

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.

Tarmil avatar Tarmil commented on August 18, 2024

That's a great idea!

from fsharp.systemtextjson.

vilinski avatar vilinski commented on August 18, 2024

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.

vilinski avatar vilinski commented on August 18, 2024

Agree, though that's their fault if they model option of option or list of option, etc. :)

from fsharp.systemtextjson.

Tarmil avatar Tarmil commented on August 18, 2024

Closing as this was released in v0.4 (the union issue is handled in #16).

from fsharp.systemtextjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.