Go 1.25 introduces experimental encoding/json/v2 and encoding/json/jsontext packages to address long-standing issues in the original encoding/json package. The new v2 API fixes behavioral flaws like invalid UTF-8 handling and duplicate JSON keys, improves performance especially for unmarshaling (up to 10x faster), and provides better streaming capabilities. The jsontext package handles JSON syntax while v2 manages semantics, offering new interfaces like MarshalerTo and UnmarshalerFrom for better performance. The original v1 package will be reimplemented using v2 under the hood, allowing gradual migration while maintaining backward compatibility.

17m read timeFrom go.dev
Post cover image
Table of contents
Introduction ¶Problems with encoding/json ¶Trying to fix encoding/json directly ¶Planning for encoding/json/v2 ¶Building on encoding/json/jsontext ¶Introducing encoding/json/v2 ¶Retroactively improving encoding/json ¶Experimenting with jsonv2 ¶

Sort: