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

Added option to not requires an EoF token when parsing JSON #7620

Merged
merged 1 commit into from Nov 3, 2022

Conversation

alexames
Copy link
Contributor

@alexames alexames commented Nov 2, 2022

Previously when parsing a JSON representation of a Flatbuffer, the parser required that the input string contain one and only one root table. This change adds a flag that removes that requirement, so that if a Flatbuffer table is embedded in some larger string the parser will simply stop parsing once it reaches the end of the root table, and does not validate that it has reached the end of the string.

This change also adds a BytesConsumed function, which returns the number of bytes the parser consumed. This is useful if the table embedded in some larger string that is being parsed, and that outer parser needs to know how many bytes the table was so that it can step over it.

@google-cla
Copy link

google-cla bot commented Nov 2, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added c++ codegen Involving generating code from schema labels Nov 2, 2022
@alexames
Copy link
Contributor Author

alexames commented Nov 2, 2022

It looks like this may be your first contribution to a Google open source project.

Not my first, but apparently my first since leaving 😛

I've signed the agreement.

Previously when parsing a JSON representation of a Flatbuffer, the
parser required that the input string contain one and only one root
table. This change adds a flag that removes that requirement, so that
if a Flatbuffer table is embedded in some larger string the parser will
simply stop parsing once it reaches the end of the root table, and does
not validate that it has reached the end of the string.

This change also adds a BytesConsumed function, which returns the number
of bytes the parser consumed. This is useful if the table embedded in
some larger string that is being parsed, and that outer parser needs to
know how many bytes the table was so that it can step over it.
Copy link
Collaborator

@CasperN CasperN left a comment

Choose a reason for hiding this comment

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

LGTM

@CasperN CasperN merged commit a4ff275 into google:master Nov 3, 2022
@alexames alexames deleted the embedded_json branch November 18, 2022 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ codegen Involving generating code from schema
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants