Skip to content

json: Properly handle trailing comma error in object decoding. #17276

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

Merged
merged 1 commit into from
Sep 17, 2014
Merged

json: Properly handle trailing comma error in object decoding. #17276

merged 1 commit into from
Sep 17, 2014

Conversation

treeman
Copy link
Contributor

@treeman treeman commented Sep 15, 2014

Closes #16945

return self.error_event(TrailingComma);
} else {
self.stack.pop();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you express this as a match instead?

match self.stack.pop() {
    Some(..) => {}
    None => return self.error_event(TrailingComma)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently json uses a custom Stack where pop does not return a value, so we need to use is_empty().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I could update pop to return the element and use match?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok, was just curious!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

@steveklabnik
Copy link
Member

😍

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 17, 2014
@bors bors merged commit fb299bd into rust-lang:master Sep 17, 2014
@treeman treeman deleted the json-comma branch September 18, 2014 03:51
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.

JSON decoding fails on trailing comma
4 participants