json-autotype
json-autotype copied to clipboard
Since unification is so generic, should 'null' values be omitted?
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.
Good point. JavaScript API distinguishes them, but best practices don't.
Should be an option --discard-nulls.