Repository navigation
internal/json: replace segmentio/encoding with encoding/json/v2 - #1287
nahapetyan-serob wants to merge 7 commits into
Conversation
5818f09 to
d0941b2
Compare
| return err | ||
| } | ||
| return NewDecoder(bytes.NewReader(data)).Decode(v) | ||
| return jsonv2.Unmarshal(data, v, caseSensitiveV1) |
There was a problem hiding this comment.
why not using the Decoder also in this case? In this way the behavior is 100% not changed
There was a problem hiding this comment.
Right. Will go back to using the Decoder.
…rotocol/go-sdk into serob/use-encoding-json-v2
|
Hi @nahapetyan-serob, thanks for this. Dropping the segmentio dependency would be a nice simplification. I noticed one interaction with a change that landed after this PR was opened, and wanted to flag it before it merges. Since #1401, A minimal check, with this branch merged into m, err := jsonrpc2.DecodeMessage([]byte(`{"jsonrpc":"2.0","id":1,"method":"tools/list","Method":"tools/call"}`))
// m.(*jsonrpc2.Request).Method is "tools/call"; on main it is "tools/list".
The merge is clean and the existing case-sensitivity tests only cover On how the two PRs relate: #1454 keeps the current dependency and only changes how |
|
Thanks @raveesh-me, good catch, confirmed. It's fixed on this branch: |
segmentio/encodingwas added in #807 for one method:DontMatchCaseInsensitiveStructFields(). Thejson/v2API does strict field-name matching natively, so the dependency isn't needed.Behavior is unchanged.
DefaultOptionsV1()keeps all v1 semantics — duplicate names permitted, invalid UTF-8 replaced, v1 null/merge handling, any-length arrays — andMatchCaseInsensitiveNames(false)overrides the one we don't want. No v2 strictness is adopted here.internal/json/json_test.gois untouched and passes as-is.UnmarshalUseNumber stays on the v1 decoder and remains case-insensitive: no public API combines UseNumber with strict matching.
go-json-experiment/jsonhosts a mirror ofencoding/json/v2with thegoexperiment.jsonv2build tag (which is enabled by default on Go 1.27)Breaking: go.mod goes 1.25.0 → 1.26 (the dependency declares it); Go 1.25 is no longer supported. CI matrix ["1.25","1.26"] → ["1.26","1.27"], which also covers both of the dependency's build paths.