Content-Length: 294949 | pFad | http://github.com/postgrespro/postgres/commit/fa43782c2ac5d881a9085d39312c7d2552928fdd

F4 Add JsonValueInitArray(), JsonValueInitObject() · postgrespro/postgres@fa43782 · GitHub
Skip to content

Commit fa43782

Browse files
author
Nikita Glukhov
committed
Add JsonValueInitArray(), JsonValueInitObject()
1 parent 47f08bd commit fa43782

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/include/utils/json_generic.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,29 @@ JsonValueInitBinary(JsonValue *val, JsonContainer *cont)
254254
return val;
255255
}
256256

257+
static inline JsonValue *
258+
JsonValueInitObject(JsonValue *val, int nPairs, int nPairsAllocated)
259+
{
260+
val->type = jbvObject;
261+
val->val.object.nPairs = nPairs;
262+
val->val.object.pairs = nPairsAllocated ?
263+
palloc(sizeof(JsonPair) * nPairsAllocated) : NULL;
264+
265+
return val;
266+
}
267+
268+
static inline JsonValue *
269+
JsonValueInitArray(JsonValue *val, int nElems, int nElemsAllocated,
270+
bool rawScalar)
271+
{
272+
val->type = jbvArray;
273+
val->val.array.nElems = nElems;
274+
val->val.array.elems = nElemsAllocated ?
275+
palloc(sizeof(JsonValue) * nElemsAllocated) : NULL;
276+
val->val.array.rawScalar = rawScalar;
277+
return val;
278+
}
279+
257280
extern Json *JsonValueToJson(JsonValue *val);
258281
extern Datum JsonbValueToOrigJsonbDatum(JsonValue *val, Json *origjs);
259282
extern JsonValue *JsonToJsonValue(Json *json, JsonValue *jv);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/fa43782c2ac5d881a9085d39312c7d2552928fdd

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy