| 1 | // Copyright 2025 The Go MCP SDK Authors. All rights reserved. |
| 2 | // Use of this source code is governed by the license |
| 3 | // that can be found in the LICENSE file. |
| 4 | |
| 5 | // Package json provides internal JSON utilities. |
| 6 | |
| 7 | package json |
| 8 | |
| 9 | import ( |
| 10 | "bytes" |
| 11 | "io" |
| 12 | |
| 13 | "github.com/segmentio/encoding/json" |
| 14 | ) |
| 15 | |
| 16 | type Decoder struct { |
| 17 | dec *json.Decoder |
| 18 | } |
| 19 | |
| 20 | func NewDecoder(r io.Reader) *Decoder { |
| 21 | dec := json.NewDecoder(r) |
| 22 | dec.DontMatchCaseInsensitiveStructFields() |
| 23 | return &Decoder{dec: dec} |
| 24 | } |
| 25 | |
| 26 | func (d *Decoder) Decode(v any) error { |
| 27 | return d.dec.Decode(v) |
| 28 | } |
| 29 | |
| 30 | func Unmarshal(data []byte, v any) error { |
| 31 | return NewDecoder(bytes.NewReader(data)).Decode(v) |
| 32 | } |