# Go 1.27 ships a new JSON API that rejects duplicate keys and invalid UTF-8

Original title: A New Go API for JSON

> Hacker News story 50369106 · language: en · submitted 2026-11-04
> Web version: https://zeli.app/story/50369106
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 385 · by [olexsmir](<https://news.ycombinator.com/user?id=olexsmir>) · 💬 199
[original](<https://go.dev/blog/jsonv2>) · [HN discussion](<https://news.ycombinator.com/item?id=50369106>)

## Summary

Go 1.27 introduces encoding/json/v2 and jsontext, a stable redesign of the standard library's JSON support. The new packages fix long-standing flaws: they reject invalid UTF-8 and duplicate object names by default, marshal nil slices as empty arrays, and offer true streaming with options passed directly to Marshal and Unmarshal. New interfaces like MarshalJSONTo and UnmarshalJSONFrom eliminate redundant parsing and allocation, making JSON handling faster and safer.

## Key quote

> The presence of a duplicate name results in a JSON value without a universally agreed upon meaning. This could be exploited by attackers in security applications and has been exploited before.

## HN discussion (199 comments)

### [asim](<https://news.ycombinator.com/item?id=50370500>)

> At this stage to me Go is the new C compiler. Quite honestly I spent 10 years or more writing Go code. At times 18 hours a day. And now with AI, I get models to write my Go code. I STILL want it to be Go code. Is that strange? No because I understand the performance and safety of Go. But I rarely write it directly anymore. Probably not at all in 6-9 months. Yet I still occasionally look at the code to see what the output looks like.
>
> So yea hopefully a nice new addition but only my prompts now matter. So need to make sure they pickup on the new API.

### [brunoborges](<https://news.ycombinator.com/item?id=50371995>)

> \> "JavaScript Object Notation (JSON) is a simple data interchange format [...]"
>
> Clearly it isn't, otherwise every language would have sorted it out by... a long time ago.

### [CamouflagedKiwi](<https://news.ycombinator.com/item?id=50369853>)

> I generally like `encoding/json/v2` and I'm glad they did it.
>
> I wish they'd left `MarshalIndent` in there though. The equivalent code is super complicated and non-obvious, so it's a pain to migrate, and it's a pain when you're banging out some quick code and want to dump some readable JSON. I suppose these days the LLMs can write the complicated version for us, of course.

### [modulovalue](<https://news.ycombinator.com/item?id=50370463>)

> I'm working on better SIMD support in Dart and one of the motivations for that work is specializing parser specifications based on schema specifications of that language.
>
> Or more concretely, if we had a parser generator + json parser specification that can generate efficient simdjson style parsers, then we should be able to parse json restricted to a subset of json based on a schema at least as efficiently as simdjson can parse general purpose json.
>
> That way we could have the best of both worlds, a (potentially lazy) statically type-safe model and simdjson performance!
>
> I still think that this is definitely doable, it's just that a lot of infrastructure needs to be built for it.
>
> I remember reading that Meta is doing something similar with binary formats. I find it weird that there's nothing like that for json yet.

### [dofm](<https://news.ycombinator.com/item?id=50370505>)

> I… think this is good?
>
> I'm just getting the neuron-band back together where Golang is concerned. I have done some in the past for little system tasks, but I am switching away from interpreted languages entirely for web stuff, and initially to Go, as I switch away from hand-coding to at least LLM-supported coding.
>
> So I am a bit out of date on the pain points (I never really felt pain points when I last used it, because the jobs I was doing had very small, quite Go-friendly shapes).

### [cbarrick](<https://news.ycombinator.com/item?id=50370631>)

> The fact that this took 6 years to land stood out to me.
>
> I'm not entirely surprised, and I'm glad the Go team is carefully considering their interfaces before launching. But 6 years seems like a lot of work to land a JSON API.

### [txomon](<https://news.ycombinator.com/item?id=50372538>)

> I used the jsontext package at my company when we needed to make a parser for challenging clients (specific errors for each kind of mistake) while still keeping performance, and it works like a charm.
>
> There is no introspection and speed is superb. I would definitely recommend jsontext as a parser for anything non-straightforward.

### [hoppp](<https://news.ycombinator.com/item?id=50372973>)

> I like it. I never really liked marshalling anyways, It was weird.
>
> I'm happy it's getting fixed!

---

## Cite

- Page: https://zeli.app/story/50369106
- Date: 2026-11-04
- Source: go.dev (https://go.dev/blog/jsonv2)
- Hacker News: https://news.ycombinator.com/item?id=50369106

## Other languages

- zh: https://zeli.app/zh/story/50369106 · markdown: https://zeli.app/zh/story/50369106.md
- ja: https://zeli.app/ja/story/50369106 · markdown: https://zeli.app/ja/story/50369106.md
- ko: https://zeli.app/ko/story/50369106 · markdown: https://zeli.app/ko/story/50369106.md
- de: https://zeli.app/de/story/50369106 · markdown: https://zeli.app/de/story/50369106.md
- es: https://zeli.app/es/story/50369106 · markdown: https://zeli.app/es/story/50369106.md
- ru: https://zeli.app/ru/story/50369106 · markdown: https://zeli.app/ru/story/50369106.md
