go-json-experiment / json

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

Use a concrete type for JSON pointer #30

Closed dsnet closed 2 months ago

dsnet commented 2 months ago

WARNING: This commit includes breaking changes.

Declare a jsontext.Pointer type as a named string type.

This allows us to implement a Tokens method to conveniently iterate over all the reference tokens in the pointer using the upcoming iterators support.

The new functionally is currently not tested by CI, but can be manually tested with:

GOEXPERIMENT=rangefunc go.tip test ./...
dsnet commented 2 months ago

I can imagine the following:

func (*Encoder) WriteTokens(seq iter.Seq2[Token, error]) error
func (*Decoder) ReadTokens() iter.Seq2[Token, error]

but that can be future API.