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

Json.undefined serializes to invalid Json #1735

Closed
tchaloupka opened this issue Apr 7, 2017 · 5 comments
Closed

Json.undefined serializes to invalid Json #1735

tchaloupka opened this issue Apr 7, 2017 · 5 comments

Comments

@tchaloupka
Copy link
Contributor

tchaloupka commented Apr 7, 2017

This is related to: #1442

auto json = Json();
writeln(json.serializeToPrettyJson);

Json should allways serialize to a valid Json I think. So probably to null in this case?

@dcousens
Copy link
Contributor

dcousens commented Apr 10, 2017

undefined is not valid JSON, tbh, I'm not sure why vibe.d even included it seeing as Json.emptyObject["foobar"] != Json.undefined

@thaven
Copy link
Contributor

thaven commented Apr 11, 2017

Json.undefined may be returned when referencing a key that is not present in a Json object. It should not be serialized to anything, except when at the root of the tree, then it should be serialized as null.

@dcousens
Copy link
Contributor

@thaven except Json.undefined != Json.undefined

@thaven
Copy link
Contributor

thaven commented Apr 11, 2017

@dcousens One may argue if two non-existing 'things' should be considered equal... ;-) That is probably why the type of the Json object is being compared to Json.Type.undefined.

@dcousens
Copy link
Contributor

dcousens commented Apr 11, 2017

@thaven in JS, undefined === undefined, fwiw

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

3 participants