jsonenc

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsonenc is zip's single JSON entry point.

All JSON marshalling in zip — c.JSON(), c.Bind().Body(), typed.go's generic In/Out handlers, module.go's extension envelope — goes through Marshal / Unmarshal here. There is no other JSON path.

Implementation: two build-tag-gated files swap the body. When the binary is compiled with GOEXPERIMENT=jsonv2, the import resolver can reach the stdlib's encoding/json/v2 package and the v2.go file is selected; otherwise v1.go is selected and we fall back to stdlib encoding/json. Either way callers see Marshal / Unmarshal — no v1/v2 branching in zip's own code.

Per HIP-0106 "Wire protocol stack": JSON is the boundary format (ingress → gateway → subsystem handler). Inter-subsystem calls use ZAP-typed Go values. JSON marshalling happens at most once per request, at the subsystem handler boundary, through THIS package.

Brand policy: no third-party JSON library is allowed. Stdlib only. goccy/go-json, sonic, jsoniter, and friends are NOT permitted in the Hanzo Go stack — see HIP-0106 canonical Hanzo Go stack.

Index

Constants

View Source
const Variant = "encoding/json/v2"

Variant reports which JSON implementation backs this build. zip.New() logs this once at startup so operators can confirm v2 is active.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v any) ([]byte, error)

Marshal encodes v as JSON via encoding/json/v2.

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal decodes data into v via encoding/json/v2.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL