MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / stackReturn

Method stackReturn

pkg/util/json/parser.go:268–283  ·  view source on GitHub ↗

stackReturn returns json object to the top of the stack and transitions state machine to the next state.

(j JSON)

Source from the content-addressed store, hash-verified

266// stackReturn returns json object to the top of the stack
267// and transitions state machine to the next state.
268func (p *fastJSONParser) stackReturn(j JSON) (JSON, error) {
269 // If stack is now empty, we're done -- return JSON.
270 if len(p.kind) == 0 {
271 return j, nil
272 }
273
274 // Add json to array or object; arrange for next state transition.
275 if p.kind[len(p.kind)-1] == kindArray {
276 p.addArrayValue(j)
277 p.state = (*fastJSONParser).parseArrayValue
278 } else {
279 p.setObjectValue(j)
280 p.state = (*fastJSONParser).parseObjectKey
281 }
282 return nil, nil
283}
284
285var errInvalidInputToken = errors.New("invalid JSON token")
286

Callers 2

buildArrayMethod · 0.95
buildObjectMethod · 0.95

Calls 2

addArrayValueMethod · 0.95
setObjectValueMethod · 0.95

Tested by

no test coverage detected