Skip to content
New issue

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

Since unification is so generic, should 'null' values be omitted? #48

Open
alaendle opened this issue Nov 30, 2021 · 2 comments
Open

Since unification is so generic, should 'null' values be omitted? #48

alaendle opened this issue Nov 30, 2021 · 2 comments

Comments

@alaendle
Copy link

This is more a question that came to my mind will working with a relatively complex json file (following this schema: https://www.eclipse.org/unide/specification/v3/process-message/#messageDetail)

E.g. consider a simple example json like:

{
    "values": [{"a": "a"},{"b": "b"}]
}

Do we really want to write it back like:

{
    "values": [{"a": "a", "b": null},{"a": null, "b": "b"}]
}

A simple hack would be to just use this snippet to strip null value pairs before creating the object in to JSON (and remove the toEncoding implementation). If a PR is able to better explain my intention just let me know and I provide a draft.
https://gist.github.com/alanz/2465584#file-simple-hs-L21-L22

I know that this might start an endless discussion about the semantic of "null" - but that is not my point, I think a (great, thanks!) tool like json-autotype couldn't support any corner case; so I wondered what is the most pragmatic interpretation in such a case. And since I haven't found any related issue I created this one. But please feel free to just close this issue if you consider this thing as already discussed.

@mgajda
Copy link
Collaborator

mgajda commented Mar 4, 2022

Good point.
JavaScript API distinguishes them, but best practices don't.

@mgajda
Copy link
Collaborator

mgajda commented Mar 4, 2022

Should be an option --discard-nulls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants