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

Throw exception when calling JsonWriter.name outside JSON object #2476

Conversation

Marcono1234
Copy link
Collaborator

Purpose

Follow-up for #2475
Closes #2407

Description

Previous fix in #2475 only covered writing name as top level value, but not when trying to write name inside JSON array.

Checklist

  • New code follows the Google Java Style Guide
  • If necessary, new public API validates arguments, for example rejects null
  • New public API has Javadoc
    • Javadoc uses @since $next-version$
      ($next-version$ is a special placeholder which is automatically replaced during release)
  • If necessary, new unit tests have been added
    • Assertions in unit tests use Truth, see existing tests
    • No JUnit 3 features are used (such as extending class TestCase)
    • If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
  • mvn clean verify javadoc:jar passes without errors

@Marcono1234 Marcono1234 changed the title Throw exception when calling JsonWriter.name outside object Throw exception when calling JsonWriter.name outside JSON object Aug 22, 2023
Previous fix in 392cc65 only covered writing
name as top level value, but not when trying to write name inside JSON array.

Removed `stackSize == 0` check from `JsonWriter.name` because that is done
already by `peek()` call.
@Marcono1234 Marcono1234 force-pushed the marcono1234/JsonWriter-name-not-in-object branch from ad9abcf to 07c38bc Compare August 22, 2023 20:27
Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

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

Thanks!

@eamonnmcmanus eamonnmcmanus merged commit 70bda4b into google:main Aug 29, 2023
9 checks passed
@Marcono1234 Marcono1234 deleted the marcono1234/JsonWriter-name-not-in-object branch August 29, 2023 22:10
tibor-universe pushed a commit to getuniverse/gson that referenced this pull request Sep 14, 2024
…oogle#2476)

Previous fix in 392cc65 only covered writing
name as top level value, but not when trying to write name inside JSON array.

Removed `stackSize == 0` check from `JsonWriter.name` because that is done
already by `peek()` call.
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.

JsonWriter.name does not throw exception when not inside JSON object
2 participants