Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef JSONAPI_H
00015 #define JSONAPI_H
00016
00017 #include "lib/stringinfo.h"
00018
00019 typedef enum
00020 {
00021 JSON_TOKEN_INVALID,
00022 JSON_TOKEN_STRING,
00023 JSON_TOKEN_NUMBER,
00024 JSON_TOKEN_OBJECT_START,
00025 JSON_TOKEN_OBJECT_END,
00026 JSON_TOKEN_ARRAY_START,
00027 JSON_TOKEN_ARRAY_END,
00028 JSON_TOKEN_COMMA,
00029 JSON_TOKEN_COLON,
00030 JSON_TOKEN_TRUE,
00031 JSON_TOKEN_FALSE,
00032 JSON_TOKEN_NULL,
00033 JSON_TOKEN_END,
00034 } JsonTokenType;
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 typedef struct JsonLexContext
00051 {
00052 char *input;
00053 int input_length;
00054 char *token_start;
00055 char *token_terminator;
00056 char *prev_token_terminator;
00057 JsonTokenType token_type;
00058 int lex_level;
00059 int line_number;
00060 char *line_start;
00061 StringInfo strval;
00062 } JsonLexContext;
00063
00064 typedef void (*json_struct_action) (void *state);
00065 typedef void (*json_ofield_action) (void *state, char *fname, bool isnull);
00066 typedef void (*json_aelem_action) (void *state, bool isnull);
00067 typedef void (*json_scalar_action) (void *state, char *token, JsonTokenType tokentype);
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 typedef struct jsonSemAction
00078 {
00079 void *semstate;
00080 json_struct_action object_start;
00081 json_struct_action object_end;
00082 json_struct_action array_start;
00083 json_struct_action array_end;
00084 json_ofield_action object_field_start;
00085 json_ofield_action object_field_end;
00086 json_aelem_action array_element_start;
00087 json_aelem_action array_element_end;
00088 json_scalar_action scalar;
00089 } jsonSemAction, *JsonSemAction;
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 extern void pg_parse_json(JsonLexContext *lex, JsonSemAction sem);
00101
00102
00103
00104
00105
00106
00107
00108 extern JsonLexContext *makeJsonLexContext(text *json, bool need_escapes);
00109
00110 #endif