MCPcopy Create free account
hub / github.com/documentdb/documentdb / bson_in

Function bson_in

pg_documentdb_core/src/io/bson_io.c:103–124  ·  view source on GitHub ↗

* bson_in converts an extended json text format string to a binary serialized bson document. */

Source from the content-addressed store, hash-verified

101 * bson_in converts an extended json text format string to a binary serialized bson document.
102 */
103Datum
104bson_in(PG_FUNCTION_ARGS)
105{
106 char *arg = PG_GETARG_CSTRING(0);
107
108 pgbson *bson;
109 if (arg == NULL)
110 {
111 bson = NULL;
112 }
113 else if (IsBsonHexadecimalString(arg))
114 {
115 bson = PgbsonInitFromHexadecimalString(arg);
116 }
117 else
118 {
119 /* It's a json string use json deserialization */
120 bson = PgbsonInitFromJson(arg);
121 }
122
123 PG_RETURN_POINTER(bson);
124}
125
126
127/*

Callers

nothing calls this directly

Calls 3

IsBsonHexadecimalStringFunction · 0.85
PgbsonInitFromJsonFunction · 0.85

Tested by

no test coverage detected