Skip to content

JS: Tolerate trailing commas in JSON objects #19393

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 2 commits into from
Apr 29, 2025

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Apr 28, 2025

Stops the extractor from complaining about trailing commas in JSON objects.

When preparing #19267 I somehow convinced myself that this was already working for JSON objects, but it has the exact same issue.

@asgerf asgerf added the no-change-note-required This PR does not need a change note label Apr 28, 2025
@github-actions github-actions bot added the JS label Apr 28, 2025
@asgerf asgerf marked this pull request as ready for review April 28, 2025 11:06
@Copilot Copilot AI review requested due to automatic review settings April 28, 2025 11:06
@asgerf asgerf requested a review from a team as a code owner April 28, 2025 11:06
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the JSON parser logic so that trailing commas in JSON objects are tolerated rather than triggering an error.

  • Removed the check that raised an error for trailing commas in JSON objects.
  • Aligns the extractor behavior with updated expectations for JSON object formatting.
Files not reviewed (2)
  • javascript/extractor/tests/json/input/object-trailing-comma.json: Language not supported
  • javascript/extractor/tests/json/output/trap/object-trailing-comma.json.trap: Language not supported
Comments suppressed due to low confidence (1)

javascript/extractor/src/com/semmle/js/parser/JSONParser.java:154

  • It would be helpful to add a comment explaining that trailing commas in JSON objects are intentionally allowed per the updated requirements, to aid future maintainability.
if (!needsComma) {

Copy link
Contributor

@Napalys Napalys left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@asgerf asgerf merged commit 6e64a22 into github:main Apr 29, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants