#include "lib/stringinfo.h"
Go to the source code of this file.
Data Structures | |
struct | JsonLexContext |
struct | jsonSemAction |
Typedefs | |
typedef struct JsonLexContext | JsonLexContext |
typedef void(* | json_struct_action )(void *state) |
typedef void(* | json_ofield_action )(void *state, char *fname, bool isnull) |
typedef void(* | json_aelem_action )(void *state, bool isnull) |
typedef void(* | json_scalar_action )(void *state, char *token, JsonTokenType tokentype) |
typedef struct jsonSemAction | jsonSemAction |
typedef struct jsonSemAction * | JsonSemAction |
Enumerations | |
enum | JsonTokenType { JSON_TOKEN_INVALID, JSON_TOKEN_STRING, JSON_TOKEN_NUMBER, JSON_TOKEN_OBJECT_START, JSON_TOKEN_OBJECT_END, JSON_TOKEN_ARRAY_START, JSON_TOKEN_ARRAY_END, JSON_TOKEN_COMMA, JSON_TOKEN_COLON, JSON_TOKEN_TRUE, JSON_TOKEN_FALSE, JSON_TOKEN_NULL, JSON_TOKEN_END } |
Functions | |
void | pg_parse_json (JsonLexContext *lex, JsonSemAction sem) |
JsonLexContext * | makeJsonLexContext (text *json, bool need_escapes) |
typedef void(* json_aelem_action)(void *state, bool isnull) |
typedef void(* json_ofield_action)(void *state, char *fname, bool isnull) |
typedef void(* json_scalar_action)(void *state, char *token, JsonTokenType tokentype) |
typedef void(* json_struct_action)(void *state) |
typedef struct JsonLexContext JsonLexContext |
typedef struct jsonSemAction * JsonSemAction |
typedef struct jsonSemAction jsonSemAction |
enum JsonTokenType |
Definition at line 19 of file jsonapi.h.
{ JSON_TOKEN_INVALID, JSON_TOKEN_STRING, JSON_TOKEN_NUMBER, JSON_TOKEN_OBJECT_START, JSON_TOKEN_OBJECT_END, JSON_TOKEN_ARRAY_START, JSON_TOKEN_ARRAY_END, JSON_TOKEN_COMMA, JSON_TOKEN_COLON, JSON_TOKEN_TRUE, JSON_TOKEN_FALSE, JSON_TOKEN_NULL, JSON_TOKEN_END, } JsonTokenType;
JsonLexContext* makeJsonLexContext | ( | text * | json, | |
bool | need_escapes | |||
) |
Definition at line 240 of file json.c.
References JsonLexContext::input, JsonLexContext::input_length, JsonLexContext::line_number, JsonLexContext::line_start, makeStringInfo(), palloc0(), JsonLexContext::strval, JsonLexContext::token_terminator, VARDATA, and VARSIZE.
Referenced by each_worker(), get_json_object_as_hash(), get_worker(), json_array_elements(), json_array_length(), json_in(), json_object_keys(), json_populate_recordset(), and json_recv().
{ JsonLexContext *lex = palloc0(sizeof(JsonLexContext)); lex->input = lex->token_terminator = lex->line_start = VARDATA(json); lex->line_number = 1; lex->input_length = VARSIZE(json) - VARHDRSZ; if (need_escapes) lex->strval = makeStringInfo(); return lex; }
void pg_parse_json | ( | JsonLexContext * | lex, | |
JsonSemAction | sem | |||
) |
Definition at line 263 of file json.c.
References json_lex(), JSON_PARSE_END, JSON_TOKEN_ARRAY_START, JSON_TOKEN_END, JSON_TOKEN_OBJECT_START, lex_expect(), lex_peek(), parse_array(), parse_object(), and parse_scalar().
Referenced by each_worker(), get_json_object_as_hash(), get_worker(), json_array_elements(), json_array_length(), json_in(), json_object_keys(), json_populate_recordset(), and json_recv().
{ JsonTokenType tok; /* get the initial token */ json_lex(lex); tok = lex_peek(lex); /* parse by recursive descent */ 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); /* json can be a bare scalar */ } lex_expect(JSON_PARSE_END, lex, JSON_TOKEN_END); }