MCPcopy Create free account
hub / github.com/blues/note / tokenPrepareForDecode

Method tokenPrepareForDecode

jsonxt/stream.go:305–332  ·  view source on GitHub ↗

advance tokenstate from a separator state to a value state

()

Source from the content-addressed store, hash-verified

303
304// advance tokenstate from a separator state to a value state
305func (dec *Decoder) tokenPrepareForDecode() error {
306 // Note: Not calling peek before switch, to avoid
307 // putting peek into the standard Decode path.
308 // peek is only called when using the Token API.
309 switch dec.tokenState {
310 case tokenArrayComma:
311 c, err := dec.peek()
312 if err != nil {
313 return err
314 }
315 if c != ',' {
316 return &SyntaxError{"expected comma after array element", dec.offset()}
317 }
318 dec.scanp++
319 dec.tokenState = tokenArrayValue
320 case tokenObjectColon:
321 c, err := dec.peek()
322 if err != nil {
323 return err
324 }
325 if c != ':' {
326 return &SyntaxError{"expected colon after object key", dec.offset()}
327 }
328 dec.scanp++
329 dec.tokenState = tokenObjectValue
330 }
331 return nil
332}
333
334func (dec *Decoder) tokenValueAllowed() bool {
335 switch dec.tokenState {

Callers 1

DecodeMethod · 0.95

Calls 2

peekMethod · 0.95
offsetMethod · 0.95

Tested by

no test coverage detected