Skip to content

Migrate from encoding/json to encoding/json/v2 and encoding/json/jsontext - #90

Merged
tangrufus merged 3 commits into
mainfrom
claude/update-encoding-json-usage
Aug 21, 2026
Merged

tangrufus merged 3 commits into
mainfrom
claude/update-encoding-json-usage

Conversation

@Claude

@Claude Claude AI commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Go 1.27 ships encoding/json/v2 (semantic JSON) and encoding/json/jsontext (syntactic JSON) as standard library packages. This PR migrates all encoding/json v1 usage to these new packages.

Changes

audit.go — semantic unmarshaling

  • Import encoding/json/v2
  • json.Unmarshal → jsonv2.Unmarshal
  • Existing UnmarshalJSON([]byte) error methods remain — v2 still honours the Unmarshaler interface

composer_lock.go — streaming/syntactic decoder

  • Import encoding/json/jsontext
  • *json.Decoder / json.NewDecoder → *jsontext.Decoder / jsontext.NewDecoder
  • json.Delim → jsontext.Kind; delimiter constants replace rune literals ('{' → jsontext.KindBeginObject, etc.)
  • decoder.More() → decoder.PeekKind() != jsontext.KindEnd{Object,Array}
  • decoder.Token() → decoder.ReadToken(); token type assertions replaced with tok.Kind() / tok.String()
  • skipJSONValue removed — replaced by the built-in decoder.SkipValue()

composer_lock_test.go

  • Updated decoder construction and type references to jsontext
  • skipJSONValue(dec) → dec.SkipValue()
  • json.Delim literal values replaced with jsontext.Kind constants

@tangrufus tangrufus changed the title Migrate from encoding/json to encoding/json/v2 and encoding/json/jsontext Migrate from encoding/json to encoding/json/v2 and encoding/json/jsontext Aug 21, 2026
@tangrufus
tangrufus requested a balanced review from Copilot August 21, 2026 19:57
@tangrufus
tangrufus marked this pull request as ready for review August 21, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Migrates JSON parsing to Go 1.27’s v2 semantic and syntactic APIs.

Changes:

  • Uses encoding/json/v2 for audit unmarshaling.
  • Uses jsontext.Decoder for composer.lock streaming.
  • Updates decoder tests and malformed-input coverage.

Reviewed changes

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

File Description
audit.go Migrates semantic unmarshaling.
composer_lock.go Migrates token-based parsing and value skipping.
composer_lock_test.go Updates tests for jsontext.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tangrufus
tangrufus merged commit 0d34493 into main Aug 21, 2026
13 of 15 checks passed
@tangrufus
tangrufus deleted the claude/update-encoding-json-usage branch August 21, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants