fxamacker / cbor

CBOR codec (RFC 8949) with CBOR tags, Go struct tags (toarray, keyasint, omitempty), float64/32/16, big.Int, and fuzz tested billions of execs.
MIT License
710 stars 59 forks source link

feature: add ScalarMarshaler and ScalarUnmarshaler interfaces #568

Open x448 opened 1 month ago

x448 commented 1 month ago

ScalarMarshaler and ScalarUnmarshaler interfaces were added to the encoding package in golang/go:

Description from https://go-review.googlesource.com/c/go/+/553176

encoding/json: handle encoding.ScalarMarshaler and encoding.ScalarUnmarshaler

Per discussion on https://go.dev/issue/56235, Marshal checks for ScalarMarshaler strictly after TextMarshaler, and Unmarshal delegates to TextUnmarshaler or ScalarUnmarshaler according to whether the corresponding JSON value is a string, Boolean, or number. Neither function handles a complex128 type argument to the interfaces.

fxamacker commented 1 month ago

Thanks for opening this issue. I will look into it.