Best of Anton ZhiyanovJune 2025

  1. 1
    Article
    Avatar of antonzAnton Zhiyanov·45w

    JSON evolution in Go: from v1 to v2

    Go 1.25 introduces json/v2 package with significant changes from v1. Key improvements include new MarshalWrite/UnmarshalRead functions for direct I/O operations, streaming encode/decode via jsontext package, configurable options for formatting and behavior, enhanced field tags (inline, format, unknown), flexible custom marshalers with MarshalFunc/UnmarshalFunc, and changed default behaviors (nil slices/maps marshal to []/{}). Performance shows similar marshaling speed but 2.7x-10.2x faster unmarshaling. The package remains experimental requiring GOEXPERIMENT=jsonv2 flag.