jet / vertigo.json Goto Github PK
View Code? Open in Web Editor NEWA reflection-based JSON (de)serialization library written in and for F#
License: Other
A reflection-based JSON (de)serialization library written in and for F#
License: Other
Currently if we have something like
type A = {
x: string option
y: string option
}
both x and y are deserialized into None type for both cases where they are missing and null in the original json.
There should be an option to deserialize the json such that the null fields are differentiable from the missing fields in the final obj.
When serializing from a map, and some values are None, Vertigo has exceptions.
Sample code
let l = ["a", (Some (1 :> obj))]
printfn "json: %s" (l |> Map.ofList |> Json.serialize)
Exception:
Unhandled Exception: System.Exception: Unknown type: Type=Object
at Vertigo.Json.Internals.NonOption$cont@204(JsonConfig config, Object value, Type t, Unit unitVar)
at Vertigo.Json.Internals.Serialize.NonOption(JsonConfig config, Type t, Object value, JsonProperty attr)
at Vertigo.Json.Internals.Serialize.Option(JsonConfig config, Type t, Object o, JsonProperty attr)
at [email protected](Object o)
at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr)
at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable`1 source)
at Vertigo.Json.Internals.Serialize.Map(JsonConfig config, IEnumerable kvps)
at Vertigo.Json.Json.serialize(Object objekt)
type private Person =
{
firstName: string
lastName: string
}
let x =
{
firstName = "John"
lastName = "Doe"
}
Json.serialize x
The above snippet throws an error saying that the type is not a Record. It would be great if the error message could identify that the type is inaccessible, or suggest making sure that the type is publicly scoped.
"Value is missing for optional field and NullRequiredForNone policy is used"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.