json/v2 is fixing many of Go's JSON quirks

Опубликовано: 13 Апрель 2026
на канале: Dreams of Code
32,741
1.4k

Click this link https://boot.dev/?promo=DREAMSOFCODE and use my code DREAMSOFCODE to get 25% off your first payment for boot.dev.

The new experimental "encoding/json/v2" package brings a number of different improvements to both JSON marshaling and unmarshaling in Go. So much so that I thought it would be worthwhile doing a video on.

*Amendments/Mistakes*:
09:10 - (Resolved) The double WithMarshalers does not work (as the video shows) This was my misunderstanding. Instead it needs to be via the JoinMarshalers, will edit this out if possible!

Links:
Go 1.25 release notes: https://go.dev/doc/go1.25
encoding/json/v2 documentation:
json/v2 proposal: https://pkg.go.dev/encoding/json/v2
encoding/json/jsontext documentation: https://pkg.go.dev/encoding/json/json...
ISO8601: https://en.wikipedia.org/wiki/ISO_8601

My Gear:
Camera: https://amzn.to/3E3ORuX
Microphone: https://amzn.to/40wHBPP
Audio Interface: https://amzn.to/4jwbd8o
Headphones: https://amzn.to/4gasmla
Keyboard: ZSA Voyager

Join this channel to get access to perks:
   / @dreamsofcode  

Join Discord:   / discord  
Join Twitter:   / dreamsofcode_io  

00:00:00 Intro
00:01:17 Sponsor
00:02:40 Null Slices & Maps
00:05:44 json.Marshal Options
00:07:14 Custom Marshallers
00:09:14 JoinMarshalers
00:10:01 Custom Unmarshalers
00:10:46 Type Changes
00:11:14 format json struct tag
00:13:44 MarshalWrite & UnmarshalRead