Skip to content

Conversation

@knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented Sep 2, 2025

Description

This PR migrates from the experimental github.com/go-json-experiment/json package to the new encoding/json/v2 package that is available in Go 1.25 as an experimental feature.

Changes

  • Updated Go version requirement to 1.25 in go.mod
  • Replaced all imports from github.com/go-json-experiment/json to encoding/json/v2
  • Replaced all imports from github.com/go-json-experiment/json/jsontext to encoding/json/jsontext
  • Added GOEXPERIMENT=jsonv2 to the build environment in magefiles
  • Removed the dependency on github.com/go-json-experiment/json from go.mod

Context

Go 1.25 introduces experimental support for encoding/json/v2.
The new package is enabled by setting GOEXPERIMENT=jsonv2 at build time, which has been configured in our build system.

Notes

  • This uses the experimental GOEXPERIMENT=jsonv2 flag which enables the new JSON implementation
  • The changes are minimal as the API is designed to be compatible with the existing go-json-experiment package

References

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

knqyf263 and others added 6 commits September 2, 2025 09:12
This migration replaces github.com/go-json-experiment/json with
the official encoding/json/v2 package introduced in Go 1.25.

Changes:
- Update Go version to 1.25
- Replace all imports from go-json-experiment/json to encoding/json/v2
- Replace all imports from go-json-experiment/json/jsontext to encoding/json/jsontext
- Remove external dependency from go.mod
- Configure mage to use GOEXPERIMENT=jsonv2 for all build commands
- All tests pass with the experimental json/v2 package

Requires GOEXPERIMENT=jsonv2 environment variable until json/v2 becomes default.
- Update golangci-lint configuration to Go 1.25
- Add GOEXPERIMENT=jsonv2 to GitHub Actions lint step
- Update golangci-lint version in cache workflow
- Add GOEXPERIMENT=jsonv2 to magefiles (already done by user)
- Fix import ordering in all files using encoding/json/v2
- Add ENV to modernize tool invocations in magefiles
- Ensure consistent import grouping per gci rules
@knqyf263 knqyf263 self-assigned this Sep 4, 2025
@knqyf263 knqyf263 added the autoready Automatically mark PR as ready for review when all checks pass label Sep 4, 2025
@knqyf263 knqyf263 changed the title feat: migrate from go-json-experiment to encoding/json/v2 refactor: migrate from go-json-experiment to encoding/json/v2 Sep 4, 2025
@github-actions github-actions bot marked this pull request as ready for review September 4, 2025 06:17
@github-actions github-actions bot requested a review from simar7 as a code owner September 4, 2025 06:17
@github-actions github-actions bot removed the autoready Automatically mark PR as ready for review when all checks pass label Sep 4, 2025
@knqyf263
Copy link
Collaborator Author

knqyf263 commented Sep 8, 2025

@nikpivkin Can you please take a look? I remember you introduced the package. I'd request your review.
#8073

@simar7
Copy link
Member

simar7 commented Sep 10, 2025

@nikpivkin Can you please take a look? I remember you introduced the package. I'd request your review. #8073

@knqyf263 Nikita is currently away on vacation he will be back on 14th.

Copy link
Member

@simar7 simar7 left a comment

Choose a reason for hiding this comment

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

Yesterday the team published an official blog post which is a good read https://go.dev/blog/jsonv2-exp

@knqyf263
Copy link
Collaborator Author

@knqyf263 Nikita is currently away on vacation he will be back on 14th.

Thanks. Yes, I remembered that right after asking him. This PR is not urgent. I'll wait for him.

@nikpivkin nikpivkin added this pull request to the merge queue Sep 15, 2025
Merged via the queue into aquasecurity:main with commit 788f6fa Sep 15, 2025
13 checks passed
@knqyf263 knqyf263 deleted the feature/json-v2-investigation branch September 15, 2025 10:08
knqyf263 added a commit to knqyf263/trivy that referenced this pull request Sep 19, 2025
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.

4 participants