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

Function parse_object

src/common/jsonapi.c:369–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369static JsonParseErrorType
370parse_object(JsonLexContext *lex, JsonSemAction *sem)
371{
372 /*
373 * an object is a possibly empty sequence of object fields, separated by
374 * commas and surrounded by curly braces.
375 */
376 json_struct_action ostart = sem->object_start;
377 json_struct_action oend = sem->object_end;
378 JsonTokenType tok;
379 JsonParseErrorType result;
380
381 check_stack_depth();
382
383 if (ostart != NULL)
384 (*ostart) (sem->semstate);
385
386 /*
387 * Data inside an object is at a higher nesting level than the object
388 * itself. Note that we increment this after we call the semantic routine
389 * for the object start and restore it before we call the routine for the
390 * object end.
391 */
392 lex->lex_level++;
393
394 Assert(lex_peek(lex) == JSON_TOKEN_OBJECT_START);
395 result = json_lex(lex);
396 if (result != JSON_SUCCESS)
397 return result;
398
399 tok = lex_peek(lex);
400 switch (tok)
401 {
402 case JSON_TOKEN_STRING:
403 result = parse_object_field(lex, sem);
404 while (result == JSON_SUCCESS && lex_peek(lex) == JSON_TOKEN_COMMA)
405 {
406 result = json_lex(lex);
407 if (result != JSON_SUCCESS)
408 break;
409 result = parse_object_field(lex, sem);
410 }
411 break;
412 case JSON_TOKEN_OBJECT_END:
413 break;
414 default:
415 /* case of an invalid initial token inside the object */
416 result = report_parse_error(JSON_PARSE_OBJECT_START, lex);
417 }
418 if (result != JSON_SUCCESS)
419 return result;
420
421 result = lex_expect(JSON_PARSE_OBJECT_NEXT, lex, JSON_TOKEN_OBJECT_END);
422 if (result != JSON_SUCCESS)
423 return result;
424
425 lex->lex_level--;
426

Callers 3

pg_parse_jsonFunction · 0.85
parse_object_fieldFunction · 0.85
parse_array_elementFunction · 0.85

Calls 6

check_stack_depthFunction · 0.85
lex_peekFunction · 0.85
json_lexFunction · 0.85
parse_object_fieldFunction · 0.85
report_parse_errorFunction · 0.85
lex_expectFunction · 0.85

Tested by

no test coverage detected