Skip to content

Make current token kind public and accessible via Lexer.CurrentToken#308

Closed
stiletto wants to merge 1 commit intomailru:masterfrom
stiletto:master
Closed

Make current token kind public and accessible via Lexer.CurrentToken#308
stiletto wants to merge 1 commit intomailru:masterfrom
stiletto:master

Conversation

@stiletto
Copy link
Copy Markdown

Currently it's there is no way to decode dynamically typed JSON other than Lexer.Interface().

Sometimes you want to implement some kind of dynamic typing, for example accepting strings and bools, or strings and numbers and want to parse differently depending on the token kind.
Lexer.Interface makes it possible but is too powerful for simple use-cases and doesn't allow you to limit expected types to protect from malicious input - it would happily decode nested maps of nested maps.

This pull request makes tokenKind public and allows the kind of current token to be accessed via Lexer.CurrentToken()

@GoWebProd
Copy link
Copy Markdown
Collaborator

Thanks for the PR. Since the PR is old and perhaps it is irrelevant for you, I will close it. If it is relevant, open it again, resolve conflicts and I will gladly merg4e.

@GoWebProd GoWebProd closed this Apr 4, 2022
iamtakingiteasy added a commit to iamtakingiteasy/easyjson that referenced this pull request Jan 6, 2024
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.

2 participants