MACSio  0.9
Multi-purpose, Application-Centric, Scalable I/O Proxy App
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

JSON object hierarchy path query methods. More...

Macros

#define CIRCBUF_SIZE   1024
 
#define CIRCBUF_RET(STR)
 

Functions

json_bool json_object_apath_get_boolean (struct json_object *obj, char const *key_path)
 Query boolean value at specified path. More...
 
int64_t json_object_apath_get_int64 (struct json_object *obj, char const *key_path)
 Query int64_t value at specified path. More...
 
int json_object_apath_get_int (struct json_object *obj, char const *key_path)
 Query int value at specified path. More...
 
double json_object_apath_get_double (struct json_object *obj, char const *key_path)
 Query double value at specified path. More...
 
char const * json_object_apath_get_string (struct json_object *obj, char const *key_path)
 Query string value at specified path. More...
 
struct json_objectjson_object_apath_get_object (struct json_object *obj, char const *key_path)
 Query any object at specified path. More...
 
struct json_objectjson_object_apath_find_object (struct json_object *root, char const *key_path)
 
char const * json_paste_apath (char const *va_args_str, char const *first,...)
 Helper method to automatically construct paths from values. More...
 

Variables

static int circbuf_idx = 0
 
static char * circbuf_retval [CIRCBUF_SIZE]
 

Detailed Description

JSON object hierarchy path query methods.

These methods allow querying of a large, JSON object hiearchy using a unix-style path for the keys (e.g. "/foo/bar/gorfo"). These alternative path (or apath) methods support object hierarchies with intermediate arrays. For example, the path "/foo/bar/16/gorfo" where 'bar' is an array object and '16' is the index of the 'bar' array we want to query is allowed. Thus, "/foo/bar/16/gorfo" is conceptually equivalent to "/foo/bar[16]/gorfo". However, if the object at the path "/foo/bar" is not an array and is instead a normal object, then if it contains a member whose key is the string "16", then that path will be queried. Likewise, the path "/gorfo/32/11/dims" where "gorfo" is an array object whose members in turn are also array objects works by first finding the array at index 32 in the "gorfo" array and then finding the object at index 11 in that array and then finally the "dims" member of that object. In short, whenever possible, the apath methods try to prefer treating path components consisting entirely of numbers as indices into arrays. When this fails at any point in the query process, then the numbers are treated as literal strings to form the key strings to query. These methods also do sane casting (e.g. type coercion) to caller's return type whenever needed.

Macro Definition Documentation

#define CIRCBUF_SIZE   1024

Definition at line 1834 of file json_object.c.

#define CIRCBUF_RET (   STR)
Value:
{ \
circbuf_retval[circbuf_idx] = strdup(STR); \
return retval; \
}
#define CIRCBUF_SIZE
Definition: json_object.c:1834
static char * circbuf_retval[CIRCBUF_SIZE]
Definition: json_object.c:1836
static int circbuf_idx
Definition: json_object.c:1835

Definition at line 1837 of file json_object.c.

Function Documentation

json_bool json_object_apath_get_boolean ( struct json_object obj,
char const *  key_path 
)

Query boolean value at specified path.

For return and type corecion, see json_object_path_get_boolean().

Definition at line 1702 of file json_object.c.

int64_t json_object_apath_get_int64 ( struct json_object obj,
char const *  key_path 
)

Query int64_t value at specified path.

For return and type corecion, see json_object_path_get_int64().

Definition at line 1739 of file json_object.c.

int json_object_apath_get_int ( struct json_object obj,
char const *  key_path 
)

Query int value at specified path.

For return and type corecion, see json_object_path_get_int().

Definition at line 1782 of file json_object.c.

double json_object_apath_get_double ( struct json_object obj,
char const *  key_path 
)

Query double value at specified path.

For return and type corecion, see json_object_path_get_double().

Definition at line 1796 of file json_object.c.

char const* json_object_apath_get_string ( struct json_object obj,
char const *  key_path 
)

Query string value at specified path.

For return and type corecion, see json_object_path_get_string().

Definition at line 1852 of file json_object.c.

struct json_object* json_object_apath_get_object ( struct json_object obj,
char const *  key_path 
)

Query any object at specified path.

For return and type corecion, see json_object_path_get_any().

Definition at line 1872 of file json_object.c.

struct json_object* json_object_apath_find_object ( struct json_object root,
char const *  key_path 
)

Definition at line 1879 of file json_object.c.

char const* json_paste_apath ( char const *  va_args_str,
char const *  first,
  ... 
)

Helper method to automatically construct paths from values.

This is an internal method called indirectly from JsonGetXXX convenience macros to automatically construct the path string from arguments.

Currently, this method works only for cases of strings intermingled with integer variables being used for array indices.

Parameters
[in]va_args_strThe string representation of all the arguments
[in]firstThe first argument must always be a string

Definition at line 1920 of file json_object.c.

Variable Documentation

int circbuf_idx = 0
static

Definition at line 1835 of file json_object.c.

char* circbuf_retval[CIRCBUF_SIZE]
static

Definition at line 1836 of file json_object.c.