Giter Site home page Giter Site logo

Comments (9)

vsapronov avatar vsapronov commented on May 22, 2024 2

Sorry, I was distracted by something. Will do my best to make a release with the fix this week.

from fsharp.json.

vsapronov avatar vsapronov commented on May 22, 2024 1

I meant more my mistake that I never considered "enum" style use case for DU.
I will fix this but probably in the next major release as it breaks backward compatibility.

from fsharp.json.

vsapronov avatar vsapronov commented on May 22, 2024

Hmmm, I think it's a mistake. I will check more and come back with some solution.

from fsharp.json.

drhumlen avatar drhumlen commented on May 22, 2024

It depends on who your consumer is. If it's only for serializing F# to F#, then it's fine as it is. But I would be very surprised to see this type definition real typescript code:

type LogEntry = {
  message: string;
  level: {Info: []} | {Warn: []} | {Error: []};
}

and then

if ('Info' in logEntry.level) {
   return <InfoIcon />
} else if (....

you get the picture. It's very unnatural for an API-consumer.

I realize there's probably some technical edge-cases though.

from fsharp.json.

dpraimeyuu avatar dpraimeyuu commented on May 22, 2024

hi @vsapronov ! Have you had chance to work on that issue? Is there anything I could help with? :-) I also ran into similar issue mentioned in the first comment.

from fsharp.json.

pkese avatar pkese commented on May 22, 2024

I'm having a similar issue with a list of Enums

type MailFlag = | AirMail | Priority | Confidential | InformDelivery
type Mail = {
   address: string
   flags: MailFlag list
}

and data

{
  "address": "somewhere",
  "flags": ["Priority", "InformDelivery"]
}

from fsharp.json.

dpraimeyuu avatar dpraimeyuu commented on May 22, 2024

Hi @vsapronov ! Have you had chance to find a solution? 😄

from fsharp.json.

vsapronov avatar vsapronov commented on May 22, 2024

Please try version 0.4.0 and let me know if it works for you.

from fsharp.json.

vsapronov avatar vsapronov commented on May 22, 2024

Here's documentation: https://github.com/vsapronov/FSharp.Json/blob/master/README.md#union-case-without-fields

from fsharp.json.

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.