Skip to content

Allow duplicate names in package.json parsing #1321

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Jun 30, 2025

The new jsonv2 package explicitly disallows duplicate JSON names (see https://github.com/go-json-experiment/json/blob/1a886bd29d1ba88a537a14c2a85b9da9e1f9609e/v1/diff_test.go#L812), but JS doesn't care. Disable this check when parsing package.json.

Fixes #1316

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 package.json parser to allow duplicate JSON names when used in package.json files.

  • Modified the JSON unmarshal call in the parser to enable duplicate names.
  • Added a test case to verify that duplicate keys in package.json do not result in errors.
  • Introduced a helper function in expected.go to facilitate constructing expected output.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/packagejson/packagejson_test.go Added a test case to validate the parsing of duplicate JSON keys
internal/packagejson/packagejson.go Updated the JSON unmarshal call to allow duplicate names
internal/packagejson/expected.go Added the ExpectedOf helper function for cleaner expected value creation

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.

Unable to resolve packages with a duplicate key in package.json
1 participant