aboutsummaryrefslogtreecommitdiff
path: root/src/include/common/jsonapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/common/jsonapi.h')
-rw-r--r--src/include/common/jsonapi.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/include/common/jsonapi.h b/src/include/common/jsonapi.h
index c3a1b04ca71..5d1a3ef3833 100644
--- a/src/include/common/jsonapi.h
+++ b/src/include/common/jsonapi.h
@@ -118,6 +118,12 @@ typedef struct JsonLexContext
struct jsonapi_StrValType *errormsg;
} JsonLexContext;
+/*
+ * Function types for custom json parsing actions.
+ *
+ * fname will be NULL if the context has need_escapes=false, as will token for
+ * string type values.
+ */
typedef JsonParseErrorType (*json_struct_action) (void *state);
typedef JsonParseErrorType (*json_ofield_action) (void *state, char *fname, bool isnull);
typedef JsonParseErrorType (*json_aelem_action) (void *state, bool isnull);
@@ -197,12 +203,17 @@ extern JsonParseErrorType json_count_array_elements(JsonLexContext *lex,
* struct is allocated.
*
* If need_escapes is true, ->strval stores the unescaped lexemes.
+ *
+ * Setting need_escapes to true is necessary if the operation needs
+ * to reference field names or scalar string values. This is true of most
+ * operations beyond purely checking the json-validity of the source
+ * document.
+ *
* Unescaping is expensive, so only request it when necessary.
*
* If need_escapes is true or lex was given as NULL, then the caller is
* responsible for freeing the returned struct, either by calling
- * freeJsonLexContext() or (in backend environment) via memory context
- * cleanup.
+ * freeJsonLexContext() or (in backends) via memory context cleanup.
*/
extern JsonLexContext *makeJsonLexContextCstringLen(JsonLexContext *lex,
const char *json,