MCPcopy Create free account
hub / github.com/apache/cloudberry / pg_parse_json

Function pg_parse_json

src/common/jsonapi.c:178–208  ·  view source on GitHub ↗

* pg_parse_json * * Publicly visible entry point for the JSON parser. * * lex is a lexing context, set up for the json to be processed by calling * makeJsonLexContext(). sem is a structure of function pointers to semantic * action routines to be called at appropriate spots during parsing, and a * pointer to a state object to be passed to those routines. */

Source from the content-addressed store, hash-verified

176 * pointer to a state object to be passed to those routines.
177 */
178JsonParseErrorType
179pg_parse_json(JsonLexContext *lex, JsonSemAction *sem)
180{
181 JsonTokenType tok;
182 JsonParseErrorType result;
183
184 /* get the initial token */
185 result = json_lex(lex);
186 if (result != JSON_SUCCESS)
187 return result;
188
189 tok = lex_peek(lex);
190
191 /* parse by recursive descent */
192 switch (tok)
193 {
194 case JSON_TOKEN_OBJECT_START:
195 result = parse_object(lex, sem);
196 break;
197 case JSON_TOKEN_ARRAY_START:
198 result = parse_array(lex, sem);
199 break;
200 default:
201 result = parse_scalar(lex, sem); /* json can be a bare scalar */
202 }
203
204 if (result == JSON_SUCCESS)
205 result = lex_expect(JSON_PARSE_END, lex, JSON_TOKEN_END);
206
207 return result;
208}
209
210/*
211 * json_count_array_elements

Callers 3

pg_parse_json_or_ereportFunction · 0.85
json_parse_manifestFunction · 0.85

Calls 6

json_lexFunction · 0.85
lex_peekFunction · 0.85
parse_objectFunction · 0.85
parse_arrayFunction · 0.85
parse_scalarFunction · 0.85
lex_expectFunction · 0.85

Tested by

no test coverage detected