package jximport ()// ObjBytes calls f for every key in object, using byte slice as key.//// The key value is valid only until f is not returned.func ( *Decoder) ( func( *Decoder, []byte) error) error {if := .consume('{'); != nil {returnerrors.Wrap(, `"{" expected`) }if == nil {return .skipObj() }if := .incDepth(); != nil {return } , := .more()if != nil {returnerrors.Wrap(, `'"' or "}" expected`) }if == '}' {return .decDepth() } .unread()// Do not reference internal buffer for key if decoder is not buffered. // // Otherwise, subsequent reads may overwrite the key. // // See https://github.com/go-faster/jx/pull/62. := .reader == nil , := .str(value{raw: })if != nil {returnerrors.Wrap(, "field name") }if := .consume(':'); != nil {returnerrors.Wrap(, `":" expected`) }// Skip whitespace.if _, = .more(); != nil {return } .unread()if := (, .buf); != nil {returnerrors.Wrap(, "callback") } , = .more()if != nil {returnerrors.Wrap(, `"," or "}" expected`) }for == ',' { , := .str(value{raw: })if != nil {returnerrors.Wrap(, "field name") }if := .consume(':'); != nil {returnerrors.Wrap(, `":" expected`) }// Check that value exists.if _, = .more(); != nil {return } .unread()if := (, .buf); != nil {returnerrors.Wrap(, "callback") }if , = .more(); != nil {return } }if != '}' { := badToken(, .offset()-1)returnerrors.Wrap(, `"}" expected`) }return .decDepth()}// Obj reads json object, calling f on each field.//// Use ObjBytes to reduce heap allocations for keys.func ( *Decoder) ( func( *Decoder, string) error) error {if == nil {// Skipping object.return .ObjBytes(nil) }return .ObjBytes(func( *Decoder, []byte) error {return (, string()) })}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.