The Future of JSON in Go

February 25, 2024 44 min Free

Description

This talk by Joe Tsai at GopherCon 2023 explores the current state and future of JSON handling in Go, focusing on the limitations of the existing `encoding/json` package. It discusses issues such as missing functionality, API deficiencies, performance bottlenecks, and behavioral flaws, including security vulnerabilities arising from duplicate keys and case-insensitive matching. The presentation then delves into a hypothetical `encoding/json/v2` package, outlining a new API design that separates syntactic and semantic concerns and aims to improve performance and correctness. The discussion covers how to achieve better interoperability between V1 and V2 and highlights new features for customizing JSON representation, such as `omitEmpty`, `omitZero`, and `inline` struct tags, as well as improved formatting options for timestamps and other data types. The talk also presents performance benchmarks comparing V1 and V2, showing significant speedups for unmarshalling and potential for orders of magnitude improvement in pathological cases. The future of JSON in Go is presented as a collaborative effort, with a call for community feedback on the proposed changes.