@@ -118,6 +118,12 @@ typedef struct JsonLexContext
118
118
struct jsonapi_StrValType * errormsg ;
119
119
} JsonLexContext ;
120
120
121
+ /*
122
+ * Function types for custom json parsing actions.
123
+ *
124
+ * fname will be NULL if the context has need_escapes=false, as will token for
125
+ * string type values.
126
+ */
121
127
typedef JsonParseErrorType (* json_struct_action ) (void * state );
122
128
typedef JsonParseErrorType (* json_ofield_action ) (void * state , char * fname , bool isnull );
123
129
typedef JsonParseErrorType (* json_aelem_action ) (void * state , bool isnull );
@@ -197,12 +203,17 @@ extern JsonParseErrorType json_count_array_elements(JsonLexContext *lex,
197
203
* struct is allocated.
198
204
*
199
205
* If need_escapes is true, ->strval stores the unescaped lexemes.
206
+ *
207
+ * Setting need_escapes to true is necessary if the operation needs
208
+ * to reference field names or scalar string values. This is true of most
209
+ * operations beyond purely checking the json-validity of the source
210
+ * document.
211
+ *
200
212
* Unescaping is expensive, so only request it when necessary.
201
213
*
202
214
* If need_escapes is true or lex was given as NULL, then the caller is
203
215
* responsible for freeing the returned struct, either by calling
204
- * freeJsonLexContext() or (in backend environment) via memory context
205
- * cleanup.
216
+ * freeJsonLexContext() or (in backends) via memory context cleanup.
206
217
*/
207
218
extern JsonLexContext * makeJsonLexContextCstringLen (JsonLexContext * lex ,
208
219
const char * json ,
0 commit comments