}
/*
- * Get i-th value of array or object. If i < 0, then it counts from the end of
- * array/object. Note: returns pointer to statically allocated JsonbValue.
+ * Get i-th value of array or object.
+ *
+ * Note: returns pointer to statically allocated JsonbValue.
*/
JsonbValue *
getJsonbValue(char *buffer, uint32 flags, int32 i)
Assert((header & (JB_FLAG_ARRAY | JB_FLAG_OBJECT)) !=
(JB_FLAG_ARRAY | JB_FLAG_OBJECT));
- if (i >= 0)
- {
- if (i >= (header & JB_COUNT_MASK))
- return NULL;
- }
- else
- {
- if (-i > (header & JB_COUNT_MASK))
- return NULL;
+ Assert(i >= 0);
- i = (header & JB_COUNT_MASK) + i;
- }
+ if (i >= (header & JB_COUNT_MASK))
+ return NULL;
array = (JEntry *) (buffer + sizeof(header));
jbvObject,
/* Binary form of jbvArray/jbvObject */
jbvBinary
- } type;
+ } type;
uint32 size; /* Estimation size of node (including
* subnodes) */
{
uint32 len;
char *val; /* Not necessarily null-terminated */
- } string;
+ } string;
struct
{
JsonbValue *elems;
bool scalar; /* Scalar actually shares representation with
* array */
- } array;
+ } array;
struct
{
int npairs;
JsonbPair *pairs;
- } object; /* Associative data structure */
+ } object; /* Associative data structure */
struct
{
uint32 len;
char *data;
- } binary;
+ } binary;
};
};