go-json-experiment / json

Experimental implementation of a proposed v2 encoding/json package
BSD 3-Clause "New" or "Revised" License
388 stars 13 forks source link

Feature: `format` as json.Options #52

Open morlay opened 3 weeks ago

morlay commented 3 weeks ago

may marshal or unmarshal value directly, not just in struct

json.Marshal([]byte("11111"), json.Format("hex"))
dsnet commented 2 weeks ago

We considered making format a first class option, but there are gnarly questions about whether it only applies to the next top-level value or recursively across the entire tree.

morlay commented 2 weeks ago

We considered making format a first class option, but there are gnarly questions about whether it only applies to the next top-level value or recursively across the entire tree.

no idea. in fact, i prefer to use encoding.Text*arshaler instead.

I'm implementing json unmarshal with custom validation base on go-json-experiment. here is no way to pass format option in my tree walk. https://github.com/octohelm/courier/blob/main/pkg/validator/internal/value.go#L560

example: https://github.com/octohelm/courier/blob/main/pkg/validator/arshal_test.go