A simplified wrapper of the yajl library. More...
Macros | |
#define | RU_JSON_PRETTIFY 0x01 |
#define | RU_JSON_ESCAPE_SLASH 0x02 |
Typedefs | |
typedef void * | ruJson |
An opaque type representing a JSON object. More... | |
Functions | |
RUAPI ruJson | ruJsonFree (ruJson rj) |
RUAPI ruJson | ruJsonNew (int32_t flags, trans_chars ident) |
RUAPI ruJson | ruJsonStart (bool map) |
RUAPI int32_t | ruJsonStartMap (ruJson rj) |
RUAPI int32_t | ruJsonEndMap (ruJson rj) |
RUAPI int32_t | ruJsonStartArray (ruJson rj) |
RUAPI int32_t | ruJsonEndArray (ruJson rj) |
RUAPI int32_t | ruJsonSetInt (ruJson rj, int64_t val) |
RUAPI int32_t | ruJsonSetDouble (ruJson rj, double val) |
RUAPI int32_t | ruJsonSetStr (ruJson rj, trans_chars val) |
RUAPI int32_t | ruJsonSetKeyStr (ruJson rj, trans_chars key, trans_chars val) |
RUAPI int32_t | ruJsonSetKeyInt (ruJson rj, trans_chars key, int64_t val) |
RUAPI int32_t | ruJsonSetKeyDouble (ruJson rj, trans_chars key, double val) |
RUAPI int32_t | ruJsonStartKeyMap (ruJson rj, trans_chars key) |
RUAPI int32_t | ruJsonStartKeyArray (ruJson rj, trans_chars key) |
RUAPI int32_t | ruJsonWrite (ruJson rj, perm_chars *output) |
RUAPI ruJson | ruJsonParse (trans_chars jsonStr, int32_t *status) |
RUAPI rusize | ruJsonArrayLen (ruJson rj, int32_t *status) |
RUAPI perm_chars | ruJsonStr (ruJson rj, int32_t *status) |
RUAPI int64_t | ruJsonParseInt (ruJson rj, int32_t *status) |
RUAPI int64_t | ruJsonInt (ruJson rj, int32_t *status) |
RUAPI bool | ruJsonParseBool (ruJson rj, int32_t *status) |
RUAPI bool | ruJsonBool (ruJson rj, int32_t *status) |
RUAPI ruList | ruJsonKeys (ruJson rj, int32_t *status) |
Returns an ruList of keys in the current map. More... | |
RUAPI perm_chars | ruJsonKeyStr (ruJson rj, trans_chars key, int32_t *status) |
RUAPI alloc_chars | ruJsonKeyToStr (ruJson rj, trans_chars key, int32_t *status) |
RUAPI alloc_chars | ruJsonKeyStrDup (ruJson rj, trans_chars key, int32_t *status) |
RUAPI int64_t | ruJsonKeyParseInt (ruJson rj, trans_chars key, int32_t *status) |
RUAPI int64_t | ruJsonKeyInt (ruJson rj, trans_chars key, int32_t *status) |
RUAPI double | ruJsonKeyDouble (ruJson rj, trans_chars key, int32_t *status) |
RUAPI bool | ruJsonKeyParseBool (ruJson rj, trans_chars key, int32_t *status) |
RUAPI bool | ruJsonKeyBool (ruJson rj, trans_chars key, int32_t *status) |
RUAPI ruJson | ruJsonKeyMap (ruJson rj, trans_chars key, int32_t *status) |
RUAPI ruJson | ruJsonKeyArray (ruJson rj, trans_chars key, int32_t *status) |
RUAPI perm_chars | ruJsonIdxStr (ruJson rj, rusize index, int32_t *status) |
RUAPI alloc_chars | ruJsonIdxStrDup (ruJson rj, rusize index, int32_t *status) |
RUAPI int64_t | ruJsonIdxParseInt (ruJson rj, rusize index, int32_t *status) |
RUAPI int64_t | ruJsonIdxInt (ruJson rj, rusize index, int32_t *status) |
RUAPI bool | ruJsonIdxParseBool (ruJson rj, rusize index, int32_t *status) |
RUAPI bool | ruJsonIdxBool (ruJson rj, rusize index, int32_t *status) |
RUAPI double | ruJsonIdxDouble (ruJson rj, rusize index, int32_t *status) |
RUAPI ruJson | ruJsonIdxMap (ruJson rj, rusize index, int32_t *status) |
RUAPI ruJson | ruJsonIdxArray (ruJson rj, rusize index, int32_t *status) |
A simplified wrapper of the yajl library.
This is a wrapper of https://lloyd.github.io/yajl/ It wraps the the yajl_tree API for parsing small content, and the yajl_gen API for generating JSON. See ruJsonNew and ruJsonStart for generation samples and ruJsonParse for a parsing sample.
#define RU_JSON_ESCAPE_SLASH 0x02 |
#define RU_JSON_PRETTIFY 0x01 |
typedef void* ruJson |
An opaque type representing a JSON object.
RUAPI bool ruJsonBool | ( | ruJson | rj, |
int32_t * | status | ||
) |
RUAPI int32_t ruJsonEndArray | ( | ruJson | rj | ) |
End the array context started with ruJsonStartArray or ruJsonStartKeyArray
rj | JSON ctx to work on |
RUAPI int32_t ruJsonEndMap | ( | ruJson | rj | ) |
End the map context started with ruJsonStartMap or ruJsonStartKeyMap
rj | JSON ctx to work on |
Return parsed boolean of the indexed element from underlying ruJson array reference. The boolean may also be an integer 0, 1 or a quoted case insensitive true or false.
rj | ruJson in question. |
index | index under which the string resides |
status | where the RUE_OK on success or an error code will be stored. |
RUAPI perm_chars ruJsonIdxStr | ( | ruJson | rj, |
rusize | index, | ||
int32_t * | status | ||
) |
RUAPI alloc_chars ruJsonIdxStrDup | ( | ruJson | rj, |
rusize | index, | ||
int32_t * | status | ||
) |
RUAPI int64_t ruJsonInt | ( | ruJson | rj, |
int32_t * | status | ||
) |
RUAPI ruJson ruJsonKeyArray | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI bool ruJsonKeyBool | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI double ruJsonKeyDouble | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI int64_t ruJsonKeyInt | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI ruJson ruJsonKeyMap | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI bool ruJsonKeyParseBool | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
Return parsed boolean of the key element from underlying ruJson map reference. The boolean may also be an integer 0, 1 or a quoted case insensitive true or false.
rj | ruJson in question. |
key | key under which boolean resides |
status | where the RUE_OK on success or an error code will be stored. |
RUAPI int64_t ruJsonKeyParseInt | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
Returns an ruList of keys in the current map.
RUAPI perm_chars ruJsonKeyStr | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI alloc_chars ruJsonKeyStrDup | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI alloc_chars ruJsonKeyToStr | ( | ruJson | rj, |
trans_chars | key, | ||
int32_t * | status | ||
) |
RUAPI ruJson ruJsonNew | ( | int32_t | flags, |
trans_chars | ident | ||
) |
Creates a new ruJson object for generating JSON
flags | Optional ORing of RU_JSON_PRETTIFY and RU_JSON_ESCAPE_SLASH |
ident | Optional indent string to use when flags has RU_JSON_PRETTIFY set. |
Example:
RUAPI ruJson ruJsonParse | ( | trans_chars | jsonStr, |
int32_t * | status | ||
) |
Parse given string into a ruJson object.
Example:
jsonStr | |
status | where the RUE_OK on success or an error code will be stored. |
RUAPI bool ruJsonParseBool | ( | ruJson | rj, |
int32_t * | status | ||
) |
Return parsed boolean of underlying ruJson reference. The boolean may also be an integer 0, 1 or a quoted case insensitive true or false.
rj | ruJson reference pointing to an integer. |
status | where the RUE_OK on success or an error code will be stored. |
RUAPI int64_t ruJsonParseInt | ( | ruJson | rj, |
int32_t * | status | ||
) |
RUAPI int32_t ruJsonSetDouble | ( | ruJson | rj, |
double | val | ||
) |
Create an double entry in the current context
rj | JSON ctx to work on |
val | double to set |
RUAPI int32_t ruJsonSetInt | ( | ruJson | rj, |
int64_t | val | ||
) |
Create an integer entry in the current context
rj | JSON ctx to work on |
val | integer to set |
RUAPI int32_t ruJsonSetKeyDouble | ( | ruJson | rj, |
trans_chars | key, | ||
double | val | ||
) |
Create a double key value entry in the current context
rj | JSON ctx to work on |
key | key string |
val | double to set |
RUAPI int32_t ruJsonSetKeyInt | ( | ruJson | rj, |
trans_chars | key, | ||
int64_t | val | ||
) |
Create a integer key value entry in the current context
rj | JSON ctx to work on |
key | key string |
val | integer to set |
RUAPI int32_t ruJsonSetKeyStr | ( | ruJson | rj, |
trans_chars | key, | ||
trans_chars | val | ||
) |
Create a string key value entry in the current context
rj | JSON ctx to work on |
key | key string |
val | string to set |
RUAPI int32_t ruJsonSetStr | ( | ruJson | rj, |
trans_chars | val | ||
) |
Create a string entry in the current context
rj | JSON ctx to work on |
val | string to set |
RUAPI ruJson ruJsonStart | ( | bool | map | ) |
Creates a new ruJson object with a top level container for generating JSON.
Example:
The created top level array or map will be automatically closed before writing
map | true to create a map false for an array |
RUAPI int32_t ruJsonStartArray | ( | ruJson | rj | ) |
Start a new array in the current context
rj | JSON ctx to work on |
RUAPI int32_t ruJsonStartKeyArray | ( | ruJson | rj, |
trans_chars | key | ||
) |
Start a new array under given key in the current context
rj | JSON ctx to work on |
key | key string |
RUAPI int32_t ruJsonStartKeyMap | ( | ruJson | rj, |
trans_chars | key | ||
) |
Start a new map under given key in the current context
rj | JSON ctx to work on |
key | key string |
RUAPI int32_t ruJsonStartMap | ( | ruJson | rj | ) |
Start a new map in the current context
rj | JSON ctx to work on |
RUAPI perm_chars ruJsonStr | ( | ruJson | rj, |
int32_t * | status | ||
) |
RUAPI int32_t ruJsonWrite | ( | ruJson | rj, |
perm_chars * | output | ||
) |
Generate a JSON string representing the given JOSN object
rj | JSON ctx to work on |
output | where the string will be stored. User must not free. Valid until rj is freed with ruJsonFree. |