PostgreSQL Source Code  git master
json.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * json.h
4  * Declarations for JSON data type support.
5  *
6  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/utils/json.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #ifndef JSON_H
15 #define JSON_H
16 
17 #include "lib/stringinfo.h"
18 
19 typedef enum /* type categories for datum_to_json */
20 {
21  JSONTYPE_NULL, /* null, so we didn't bother to identify */
22  JSONTYPE_BOOL, /* boolean (built-in types only) */
23  JSONTYPE_NUMERIC, /* numeric (ditto) */
24  JSONTYPE_DATE, /* we use special formatting for datetimes */
27  JSONTYPE_JSON, /* JSON itself (and JSONB) */
28  JSONTYPE_ARRAY, /* array */
29  JSONTYPE_COMPOSITE, /* composite */
30  JSONTYPE_CAST, /* something with an explicit cast to JSON */
31  JSONTYPE_OTHER /* all else */
33 
34 /* functions in json.c */
35 extern void escape_json(StringInfo buf, const char *str);
36 extern char *JsonEncodeDateTime(char *buf, Datum value, Oid typid,
37  const int *tzp);
38 extern bool to_json_is_immutable(Oid typoid);
39 extern void json_categorize_type(Oid typoid, JsonTypeCategory *tcategory,
40  Oid *outfuncoid);
42  Oid outfuncoid);
43 extern Datum json_build_object_worker(int nargs, Datum *args, bool *nulls,
44  Oid *types, bool absent_on_null,
45  bool unique_keys);
46 extern Datum json_build_array_worker(int nargs, Datum *args, bool *nulls,
47  Oid *types, bool absent_on_null);
48 extern bool json_validate(text *json, bool check_unique_keys, bool throw_error);
49 
50 #endif /* JSON_H */
struct typedefs * types
Definition: ecpg.c:29
static struct @151 value
long val
Definition: informix.c:664
JsonTypeCategory
Definition: json.h:20
@ JSONTYPE_JSON
Definition: json.h:27
@ JSONTYPE_NULL
Definition: json.h:21
@ JSONTYPE_TIMESTAMP
Definition: json.h:25
@ JSONTYPE_NUMERIC
Definition: json.h:23
@ JSONTYPE_DATE
Definition: json.h:24
@ JSONTYPE_BOOL
Definition: json.h:22
@ JSONTYPE_OTHER
Definition: json.h:31
@ JSONTYPE_CAST
Definition: json.h:30
@ JSONTYPE_COMPOSITE
Definition: json.h:29
@ JSONTYPE_ARRAY
Definition: json.h:28
@ JSONTYPE_TIMESTAMPTZ
Definition: json.h:26
Datum json_build_array_worker(int nargs, Datum *args, bool *nulls, Oid *types, bool absent_on_null)
Definition: json.c:1352
Datum json_build_object_worker(int nargs, Datum *args, bool *nulls, Oid *types, bool absent_on_null, bool unique_keys)
Definition: json.c:1238
void json_categorize_type(Oid typoid, JsonTypeCategory *tcategory, Oid *outfuncoid)
Definition: json.c:166
char * JsonEncodeDateTime(char *buf, Datum value, Oid typid, const int *tzp)
Definition: json.c:375
bool json_validate(text *json, bool check_unique_keys, bool throw_error)
Definition: json.c:1684
Datum to_json_worker(Datum val, JsonTypeCategory tcategory, Oid outfuncoid)
Definition: json.c:748
void escape_json(StringInfo buf, const char *str)
Definition: json.c:1587
bool to_json_is_immutable(Oid typoid)
Definition: json.c:758
static char * buf
Definition: pg_test_fsync.c:67
uintptr_t Datum
Definition: postgres.h:411
unsigned int Oid
Definition: postgres_ext.h:31
Definition: c.h:622