Skip to content

Allow trailing comma in objects and arrays #1062

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

Closed

Conversation

kimsey0
Copy link
Contributor

@kimsey0 kimsey0 commented Oct 17, 2019

Fixes #1043.

Allows one trailing comma in objects ({ "count" : 1234, } = { "count" : 1234 }) and arrays ([1,] = [1]), which is ignored.

Introduces new feature allowTrailingCommas, which can be used to switch this on and off. It is enabled by default, unless in strict mode.

Currently only allows trailing commas in arrays if allowDroppedNullPlaceholders is off, since otherwise, we'd break clients that depend on [1,] being parsed as [1,null].

In this draft version, introduces the changes both in the legacy Reader and the modern OurReader. However, this can be changed if #1053 (comment) is handled and we allow having modern only tests.

@kimsey0
Copy link
Contributor Author

kimsey0 commented Oct 17, 2019

I expect this should bump the version. If we keep special case for allowDroppedNullPlaceholders, it might just be a minor bump, while changing the behavior for [1,] would probably be a major bump.

@cdunn2001 cdunn2001 mentioned this pull request Nov 4, 2019
@cdunn2001
Copy link
Contributor

I like this feature. I personally use trailing commas in Python all the time. But (A) this PR currently fails for AppVeyor. And (B) it's still a draft. Is that because of the problem with old versus new Reader in the tests?

@kimsey0
Copy link
Contributor Author

kimsey0 commented Nov 4, 2019

(A) just seems to be because I haven't run clang-format. I'll get that done.

(B) is because of the problem with old versus new Reader. I have currently implemented the change in both the old and new Reader, but from #1043 (comment), it sounds like I should revert the change to the old reader, since it's deprecated and shouldn't be changed. In that case, in order for the tests I have added to pass, we will need the change in 836d954 to be merged, so that the tests are only run for the new Reader.

@kimsey0
Copy link
Contributor Author

kimsey0 commented Nov 4, 2019

@cdunn2001: Would you prefer to have support for trailing commas in both the old and the new Reader, or just in the new one?

kimsey0 and others added 2 commits November 4, 2019 13:29
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 88.057% when pulling 720745e on kimsey0:allow-trailing-commas into 2eb20a9 on open-source-parsers:master.

@cdunn2001
Copy link
Contributor

Trailing "slashes"? If you mean trailing "commas", just in New is fine. But we need to be sure we have test coverage first.

@kimsey0
Copy link
Contributor Author

kimsey0 commented Nov 4, 2019

Yes, I mean trailing commas. I've edited it in the comment above.

Let's keep this pull request as a draft until #1053 is merged. Then I'll revert the changes to the old Reader.

@cdunn2001
Copy link
Contributor

We can merge #1053 after clang-format there. Then yes, we can merge this one.

@dota17 dota17 marked this pull request as ready for review November 14, 2019 02:51
@dota17
Copy link
Member

dota17 commented Nov 14, 2019

Ready for review! I think we can go to the next step now. @kimsey0

@cdunn2001
Copy link
Contributor

replaced by #1098

@cdunn2001 cdunn2001 closed this Nov 14, 2019
@kimsey0 kimsey0 deleted the allow-trailing-commas branch November 2, 2021 17:37
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

Successfully merging this pull request may close these issues.

Ignore trailing comma in objects and arrays
4 participants