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

JsonReader accepts Booleans regardless of case, with no way to find original value. #988

Open
toddobryan opened this issue Dec 29, 2016 · 1 comment
Assignees
Labels

Comments

@toddobryan
Copy link

Contrary to the spec at http://www.ietf.org/rfc/rfc7159.txt, the JsonReader class accepts not only true and false as valid Boolean values, but TRUE and FALSE, True and False, and even TrUe and fAlSe. This occurs no matter what the value of lenient is set to.

In writing my own TypeAdapter, I'd like to be able to decide whether I'll only accept true and false or whether other mixtures of case would be acceptable, but there's no public method I can find that will let me access the next token itself.

It seems like it should be possible to have peek() only return a JsonToken.BOOLEAN if the next value is really true or false and then have a JsonToken.UNQUOTED_VALUE that people could check for if they wanted to accept alternate cased versions.

Is this an oversight, a conscious design decision, or something no one else has complained about?

@Marcono1234
Copy link
Collaborator

This is at least now mentioned in the documentation for JsonReader.setLenient (see #2122) but that does not necessarily mean that this behavior is desired.

(though I am not a direct project member)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants