FSharp.Data icon indicating copy to clipboard operation
FSharp.Data copied to clipboard

Is there a way to hide properties with null values for JsonProvider?

Open nikoudel opened this issue 6 years ago • 1 comments

This piece of code:

open FSharp.Data

type ColorProvider = JsonProvider<"""
[
  {
    "color": "Red",
    "code": 15
  },
  {
    "color": "Green"
  }
]
""", SampleIsList=true>

let value = ColorProvider.Root(color = "Blue", code = None)

printf "%A" value

Produces this JSON:

{
  "color": "Blue",
  "code": null
}

Can I somehow configure the provider to skip the code property in this case?

nikoudel avatar Feb 13 '19 18:02 nikoudel

Any thoughts on how to address this or work around it? This issues is causing my generated JSON to be rejected by the server I'm integrating with. Thanks!

JeffreyPalmer avatar Dec 18 '20 19:12 JeffreyPalmer