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

Comments

Projects
None yet
3 participants
@tchaloupka
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

This comment has been minimized.

Show comment
Hide comment
@dcousens

dcousens Apr 10, 2017

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@thaven

thaven Apr 11, 2017

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@dcousens

dcousens Apr 11, 2017

Contributor

@thaven except Json.undefined != Json.undefined

Contributor

dcousens commented Apr 11, 2017

@thaven except Json.undefined != Json.undefined

@thaven

This comment has been minimized.

Show comment
Hide comment
@thaven

thaven Apr 11, 2017

Contributor

@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.

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

This comment has been minimized.

Show comment
Hide comment
@dcousens

dcousens Apr 11, 2017

Contributor

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

Contributor

dcousens commented Apr 11, 2017

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

@s-ludwig s-ludwig closed this in #1737 May 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment