We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Already discussed this one with @DZakh some time ago, but we did not really come to a conclusion and lost track of it.
When I have an object with a field of type option<'a>, e.g.
option<'a>
@schema type t = { a: string, b: option<int>, } let obj = {a: "test", b: None}
and I serialize it using S.serializeOrRaiseWith(obj, schema), I get the following JS object:
S.serializeOrRaiseWith(obj, schema)
{a: 'test', b: undefined}
I would prefer to get
{a: 'test'}
i.e., having the field b with value undefined omitted.
b
undefined
I know that b is stripped anyway when serializing the object to JSON using JSON.stringify, but:
JSON.stringify
In other use cases, such as writing the object to IndexedDB, the undefined values are not stripped.
The return type of S.serializeOrRaiseWith is JSON.t which is defined as
S.serializeOrRaiseWith
JSON.t
type rec t = | Boolean(bool) | @as(null) Null | String(string) | Number(float) | Object(Core__Dict.t<t>) | Array(array<t>)
and therefore actually cannot have undefined values.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Already discussed this one with @DZakh some time ago, but we did not really come to a conclusion and lost track of it.
When I have an object with a field of type
option<'a>
, e.g.and I serialize it using
S.serializeOrRaiseWith(obj, schema)
, I get the following JS object:I would prefer to get
i.e., having the field
b
with valueundefined
omitted.I know that
b
is stripped anyway when serializing the object to JSON usingJSON.stringify
, but:In other use cases, such as writing the object to IndexedDB, the
undefined
values are not stripped.The return type of
S.serializeOrRaiseWith
isJSON.t
which is defined asand therefore actually cannot have
undefined
values.The text was updated successfully, but these errors were encountered: