src/postgres/src/backend/utils/adt/jsonapi.c
/*
 * 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.
 */
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.
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 .
void
pg_parse_json(JsonLexContext *lex, JsonSemAction *sem)
{
	JsonTokenType tok;
	json_lex(lex);
	tok = lex_peek(lex);
	switch (tok)
	{
		case JSON_TOKEN_OBJECT_START:
			parse_object(lex, sem);
			break;
		case JSON_TOKEN_ARRAY_START:
			parse_array(lex, sem);
			break;
		default:
			parse_scalar(lex, sem); 
	}
	lex_expect(JSON_PARSE_END, lex, JSON_TOKEN_END);
}
void pg_parse_json ( JsonLexContext * lex , JsonSemAction * sem ) { JsonTokenType tok ; json_lex ( lex ) ; tok = lex_peek ( lex ) ; switch ( tok ) { case JSON_TOKEN_OBJECT_START : parse_object ( lex , sem ) ; break ; case JSON_TOKEN_ARRAY_START : parse_array ( lex , sem ) ; break ; default : parse_scalar ( lex , sem ) ; } lex_expect ( JSON_PARSE_END , lex , JSON_TOKEN_END ) ; }
pg_parse_json
 Publicly visible entry point for the JSON parser.
pg_parse_json Publicly visible entry point for the JSON parser .
/* get the initial token */ /* parse by recursive descent */ /* json can be a bare scalar */