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

Method parseTopValue

pkg/util/json/parser.go:100–121  ·  view source on GitHub ↗

parseTopValue processes top level JSON value.

(tok []byte)

Source from the content-addressed store, hash-verified

98
99// parseTopValue processes top level JSON value.
100func (p *fastJSONParser) parseTopValue(tok []byte) (JSON, error) {
101 switch tok[0] {
102 case tokenizer.ArrayStart:
103 p.pushArray()
104 return nil, nil
105 case tokenizer.ObjectStart:
106 p.pushObject()
107 return nil, nil
108 case tokenizer.Null:
109 return NullJSONValue, nil
110 case tokenizer.String:
111 return jsonString(tok[1 : len(tok)-1]), nil
112 case tokenizer.True:
113 return TrueJSONValue, nil
114 case tokenizer.False:
115 return FalseJSONValue, nil
116 case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
117 return FromNumber(json.Number(tok))
118 default:
119 return nil, errors.Newf("unexpected token %q", tok)
120 }
121}
122
123// parseArrayValue processes JSON value inside array.
124func (p *fastJSONParser) parseArrayValue(tok []byte) (JSON, error) {

Callers

nothing calls this directly

Calls 4

pushArrayMethod · 0.95
pushObjectMethod · 0.95
jsonStringTypeAlias · 0.85
FromNumberFunction · 0.85

Tested by

no test coverage detected