mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
jsonenc chose encoding/json/v2 on the goexperiment.jsonv2 tag, and Go 1.27 sets
that tag by default. Moving a module's go directive to 1.27 therefore changed what
every zip service writes: a zero number or false kept under omitempty, a nil slice
as [] and a nil map as {}, field names matched case-sensitively, map keys unsorted.
hanzoai/cloud went from green to 54 failing wire tests on that bump alone.
jsonenc is stdlib encoding/json and nothing else. Since 1.27 that API runs on the
v2 engine with v1 semantics, so the speed arrives with the toolchain and the bytes
stay put. A test pins the four differences.
Co-authored-by: Hanzo Dev <[email protected]>
10 lines
391 B
Go
10 lines
391 B
Go
package js
|
|
|
|
import "github.com/zap-proto/zip/internal/jsonenc"
|
|
|
|
// jsonMarshal / jsonUnmarshal route through zip's jsonenc package so the
|
|
// embedded-JS bridge uses the same JSON impl as the edge — one wire format,
|
|
// one way to encode it.
|
|
func jsonMarshal(v any) ([]byte, error) { return jsonenc.Marshal(v) }
|
|
func jsonUnmarshal(b []byte, v any) error { return jsonenc.Unmarshal(b, v) }
|