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

Macros

#define json_object_object_foreach(obj, key, val)
 
#define json_object_object_foreachC(obj, iter)   for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next)
 
#define json_object_object_foreach(obj, key, val)
 
#define json_object_object_foreachC(obj, iter)   for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next)
 

Functions

struct json_objectjson_object_new_object (void)
 
struct lh_tablejson_object_get_object (struct json_object *obj)
 
int json_object_object_length (struct json_object *obj)
 
void json_object_object_add (struct json_object *obj, const char *key, struct json_object *val)
 
 THIS_FUNCTION_IS_DEPRECATED (extern struct json_object *json_object_object_get(struct json_object *obj, const char *key))
 
json_bool json_object_object_get_ex (struct json_object *obj, const char *key, struct json_object **value)
 
void json_object_object_del (struct json_object *obj, const char *key)
 

Detailed Description

Macro Definition Documentation

#define json_object_object_foreach (   obj,
  key,
  val 
)
Value:
char *key;\
struct json_object *val; \
struct lh_entry *entry ## key; \
struct lh_entry *entry_next ## key = NULL; \
for(entry ## key = json_object_get_object(obj)->head; \
(entry ## key ? ( \
key = (char*)entry ## key->k, \
val = (struct json_object*)entry ## key->v, \
entry_next ## key = entry ## key->next, \
entry ## key) : 0); \
entry ## key = entry_next ## key)
Definition: linkhash.h:62
struct lh_table * json_object_get_object(struct json_object *obj)
Definition: json_object.c:380

Iterate through all keys and values of an object.

Adding keys to the object while iterating is NOT allowed.

Deleting an existing key, or replacing an existing key with a new value IS allowed.

Parameters
objthe json_object instance
keythe local name for the char* key variable defined in the body
valthe local name for the json_object* object variable defined in the body

Definition at line 387 of file json_object.h.

#define json_object_object_foreachC (   obj,
  iter 
)    for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next)

Iterate through all keys and values of an object (ANSI C Safe)

Parameters
objthe json_object instance
iterthe object iterator

Definition at line 406 of file json_object.h.

#define json_object_object_foreach (   obj,
  key,
  val 
)
Value:
char *key;\
struct json_object *val; \
struct lh_entry *entry ## key; \
struct lh_entry *entry_next ## key = NULL; \
for(entry ## key = json_object_get_object(obj)->head; \
(entry ## key ? ( \
key = (char*)entry ## key->k, \
val = (struct json_object*)entry ## key->v, \
entry_next ## key = entry ## key->next, \
entry ## key) : 0); \
entry ## key = entry_next ## key)
Definition: linkhash.h:62
struct lh_table * json_object_get_object(struct json_object *obj)
Definition: json_object.c:380

Iterate through all keys and values of an object.

Adding keys to the object while iterating is NOT allowed.

Deleting an existing key, or replacing an existing key with a new value IS allowed.

Parameters
objthe json_object instance
keythe local name for the char* key variable defined in the body
valthe local name for the json_object* object variable defined in the body

Definition at line 387 of file json_object.h.

#define json_object_object_foreachC (   obj,
  iter 
)    for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next)

Iterate through all keys and values of an object (ANSI C Safe)

Parameters
objthe json_object instance
iterthe object iterator

Definition at line 406 of file json_object.h.

Function Documentation

struct json_object * json_object_new_object ( void  )

Create a new empty object with a reference count of 1. The caller of this object initially has sole ownership. Remember, when using json_object_object_add or json_object_array_put_idx, ownership will transfer to the object/array. Call json_object_get if you want to maintain shared ownership or also add this object as a child of multiple objects or arrays. Any ownerships you acquired but did not transfer must be released through json_object_put.

Returns
a json_object of type json_type_object

Definition at line 369 of file json_object.c.

struct lh_table * json_object_get_object ( struct json_object obj)

Get the hashtable of a json_object of type json_type_object

Parameters
objthe json_object instance
Returns
a linkhash

Definition at line 380 of file json_object.c.

int json_object_object_length ( struct json_object obj)

Get the size of an object in terms of the number of fields it has.

Parameters
objthe json_object whose length to return

Definition at line 410 of file json_object.c.

void json_object_object_add ( struct json_object obj,
const char *  key,
struct json_object val 
)

Add an object field to a json_object of type json_type_object

The reference count will not be incremented. This is to make adding fields to objects in code more compact. If you want to retain a reference to an added object, independent of the lifetime of obj, you must wrap the passed object with json_object_get.

Upon calling this, the ownership of val transfers to obj. Thus you must make sure that you do in fact have ownership over this object. For instance, json_object_new_object will give you ownership until you transfer it, whereas json_object_object_get does not.

Parameters
objthe json_object instance
keythe object field name (a private copy will be duplicated)
vala json_object or NULL member to associate with the given field

Definition at line 391 of file json_object.c.

THIS_FUNCTION_IS_DEPRECATED ( extern struct json_object json_object_object_getstruct json_object *obj, const char *key)

Get the json_object associate with a given object field

No reference counts will be changed. There is no need to manually adjust reference counts through the json_object_put/json_object_get methods unless you need to have the child (value) reference maintain a different lifetime than the owning parent (obj). Ownership of the returned value is retained by obj (do not do json_object_put unless you have done a json_object_get). If you delete the value from obj (json_object_object_del) and wish to access the returned reference afterwards, make sure you have first gotten shared ownership through json_object_get (& don't forget to do a json_object_put or transfer ownership to prevent a memory leak).

Parameters
objthe json_object instance
keythe object field name
Returns
the json_object associated with the given field name
Deprecated:
Please use json_object_object_get_ex

Get the json_object associate with a given object field

No reference counts will be changed. There is no need to manually adjust reference counts through the json_object_put/json_object_get methods unless you need to have the child (value) reference maintain a different lifetime than the owning parent (obj). Ownership of the returned value is retained by obj (do not do json_object_put unless you have done a json_object_get). If you delete the value from obj (json_object_object_del) and wish to access the returned reference afterwards, make sure you have first gotten shared ownership through json_object_get (& don't forget to do a json_object_put or transfer ownership to prevent a memory leak).

Parameters
objthe json_object instance
keythe object field name
Returns
the json_object associated with the given field name
Deprecated:
Please use json_object_object_get_ex
json_bool json_object_object_get_ex ( struct json_object obj,
const char *  key,
struct json_object **  value 
)

Get the json_object associated with a given object field.

This returns true if the key is found, false in all other cases (including if obj isn't a json_type_object).

No reference counts will be changed. There is no need to manually adjust reference counts through the json_object_put/json_object_get methods unless you need to have the child (value) reference maintain a different lifetime than the owning parent (obj). Ownership of value is retained by obj.

Parameters
objthe json_object instance
keythe object field name
valuea pointer where to store a reference to the json_object associated with the given field name.

It is safe to pass a NULL value.

Returns
whether or not the key exists

Definition at line 422 of file json_object.c.

void json_object_object_del ( struct json_object obj,
const char *  key 
)

Delete the given json_object field

The reference count will be decremented for the deleted object. If there are no more owners of the value represented by this key, then the value is freed. Otherwise, the reference to the value will remain in memory.

Parameters
objthe json_object instance
keythe object field name

Definition at line 441 of file json_object.c.