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.c File Reference
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "debug.h"
#include "printbuf.h"
#include "linkhash.h"
#include "arraylist.h"
#include "json_inttypes.h"
#include "json_object.h"
#include "json_object_private.h"
#include "json_util.h"
#include "math_compat.h"

Go to the source code of this file.

Macros

#define COPYNCAST_EXTARR_DATA(SRCT, SRCP, DSTT, DSTP, NVALS)
 
#define JSON_OBJECT_EXTARR_DATA_AS(DSTT, DSTN)
 
#define CIRCBUF_SIZE   1024
 
#define CIRCBUF_RET(STR)
 

Functions

static void json_object_generic_delete (struct json_object *jso)
 
static struct json_objectjson_object_new (enum json_type o_type)
 
static int json_escape_str (struct printbuf *pb, char *str, int len)
 
struct json_objectjson_object_get (struct json_object *jso)
 
int json_object_put (struct json_object *jso)
 
int json_object_is_type (struct json_object *jso, enum json_type type)
 
enum json_type json_object_get_type (struct json_object *jso)
 
void json_object_set_serializer (json_object *jso, json_object_to_json_string_fn to_string_func, void *userdata, json_object_delete_fn *user_delete)
 
const char * json_object_to_json_string_ext (struct json_object *jso, int flags)
 
const char * json_object_to_json_string (struct json_object *jso)
 
static void indent (struct printbuf *pb, int level, int flags)
 
static int json_object_object_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
static void json_object_lh_entry_free (struct lh_entry *ent)
 
static void json_object_object_delete (struct json_object *jso)
 
struct json_objectjson_object_new_object (void)
 
struct lh_tablejson_object_get_object (struct json_object *jso)
 
void json_object_object_add (struct json_object *jso, const char *key, struct json_object *val)
 
int json_object_object_length (struct json_object *jso)
 
struct json_objectjson_object_object_get (struct json_object *jso, const char *key)
 
json_bool json_object_object_get_ex (struct json_object *jso, const char *key, struct json_object **value)
 
void json_object_object_del (struct json_object *jso, const char *key)
 
static int json_object_boolean_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
struct json_objectjson_object_new_boolean (json_bool b)
 
json_bool json_object_get_boolean (struct json_object *jso)
 
static int json_object_int_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
struct json_objectjson_object_new_int (int32_t i)
 
int32_t json_object_get_int (struct json_object *jso)
 
struct json_objectjson_object_new_int64 (int64_t i)
 
int64_t json_object_get_int64 (struct json_object *jso)
 
static int json_object_double_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
struct json_objectjson_object_new_double (double d)
 
struct json_objectjson_object_new_double_s (double d, const char *ds)
 
int json_object_userdata_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
void json_object_free_userdata (struct json_object *jso, void *userdata)
 
double json_object_get_double (struct json_object *jso)
 
static int json_object_string_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
static void json_object_string_delete (struct json_object *jso)
 
struct json_objectjson_object_new_string (const char *s)
 
struct json_objectjson_object_new_string_len (const char *s, int len)
 
const char * json_object_get_string (struct json_object *jso)
 
int json_object_get_string_len (struct json_object *jso)
 
static int json_object_array_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
static void json_object_array_entry_free (void *data)
 
static void json_object_array_delete (struct json_object *jso)
 
struct json_objectjson_object_new_array (void)
 
struct array_listjson_object_get_array (struct json_object *jso)
 
void json_object_array_sort (struct json_object *jso, int(*sort_fn)(const void *, const void *))
 
int json_object_array_length (struct json_object *jso)
 
int json_object_array_add (struct json_object *jso, struct json_object *val)
 
int json_object_array_put_idx (struct json_object *jso, int idx, struct json_object *val)
 
struct json_objectjson_object_array_get_idx (struct json_object *jso, int idx)
 
static int json_object_extarr_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
static void json_object_extarr_delete (struct json_object *jso)
 
struct json_objectjson_object_new_extarr (void const *data, enum json_extarr_type type, int ndims, int const *dims)
 
struct json_objectjson_object_new_extarr_alloc (enum json_extarr_type etype, int ndims, int const *dims)
 
enum json_extarr_type json_object_extarr_type (struct json_object *jso)
 
int json_object_extarr_nvals (struct json_object *jso)
 
int json_object_extarr_valsize (struct json_object *obj)
 
int64_t json_object_extarr_nbytes (struct json_object *obj)
 
int json_object_extarr_ndims (struct json_object *jso)
 
int json_object_extarr_dim (struct json_object *jso, int dimidx)
 
void const * json_object_extarr_data (struct json_object *jso)
 
static void json_object_enum_delete (struct json_object *jso)
 
struct json_objectjson_object_new_enum (void)
 Create a new, empty enumeration object. More...
 
void json_object_enum_add (struct json_object *jso, char const *name, int64_t val, json_bool selected)
 Add a name/value pair to an enumeration. More...
 
int json_object_enum_length (struct json_object *jso)
 Get the length (or size) of an enumeration. More...
 
char const * json_object_enum_get_idx_name (struct json_object *jso, int idx)
 Get the name of a specific name/value pair in the enumeration. More...
 
char const * json_object_enum_get_name (struct json_object *jso, int64_t val)
 Get name of value in an enumeration. More...
 
int64_t json_object_enum_get_idx_val (struct json_object *jso, int idx)
 Get the value of a specific name/value pair in the enumeration. More...
 
int64_t json_object_enum_get_val (struct json_object *jso, char const *name)
 Get value of name in an enumeration. More...
 
int64_t json_object_enum_get_choice_val (struct json_object *jso)
 Get chosen value of an enumeration. More...
 
char const * json_object_enum_get_choice_name (struct json_object *jso)
 Get chosen name of an enumeration. More...
 
static int json_object_enum_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
json_bool json_object_set_boolean (struct json_object *bool_obj, json_bool val)
 
json_bool json_object_set_enum_choice_name (struct json_object *enum_obj, char const *name)
 
json_bool json_object_set_enum_choice_val (struct json_object *enum_obj, int64_t val)
 
json_bool json_object_set_int (struct json_object *int_obj, int32_t val)
 
json_bool json_object_set_int64 (struct json_object *int_obj, int64_t val)
 
json_bool json_object_set_double (struct json_object *double_obj, double val)
 
json_bool json_object_set_string (struct json_object *string_obj, char const *val)
 
static void * json_object_apath_get_leafobj_recurse (struct json_object *src, char *key_path)
 
static struct json_objectjson_object_apath_get_leafobj (struct json_object *obj, char const *key_path)
 
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...
 
static void * json_object_path_get_leafobj_recurse (struct json_object *src, char *key_path, json_type jtype)
 
static struct json_objectjson_object_path_get_leafobj (struct json_object *obj, char const *key_path, json_type jtype)
 
json_bool json_object_path_set_boolean (struct json_object *obj, char const *key_path, json_bool val)
 
json_bool json_object_path_set_enum_choice_val (struct json_object *obj, char const *key_path, int64_t val)
 
json_bool json_object_path_set_enum_choice_name (struct json_object *obj, char const *key_path, char const *val)
 
json_bool json_object_path_set_int (struct json_object *obj, char const *key_path, int32_t val)
 
json_bool json_object_path_set_int64 (struct json_object *obj, char const *key_path, int64_t val)
 
json_bool json_object_path_set_double (struct json_object *obj, char const *key_path, double val)
 
json_bool json_object_path_set_string (struct json_object *obj, char const *key_path, char const *val)
 
int32_t json_object_path_get_int (struct json_object *src, char const *key_path)
 Get integer value for object at specified path. More...
 
int64_t json_object_path_get_int64 (struct json_object *src, char const *key_path)
 Get int64 value for object at specified path. More...
 
double json_object_path_get_double (struct json_object *src, char const *key_path)
 Get a double value for the object at specified path. More...
 
json_bool json_object_path_get_boolean (struct json_object *src, char const *key_path)
 Get boolean value for the object at specified path. More...
 
char const * json_object_path_get_string (struct json_object *src, char const *key_path)
 Get a string value for the object at specified path. More...
 
struct json_objectjson_object_path_get_array (struct json_object *src, char const *key_path)
 Get the array object at specified path. More...
 
struct json_objectjson_object_path_get_object (struct json_object *src, char const *key_path)
 Get the object at specified path. More...
 
struct json_objectjson_object_path_get_extarr (struct json_object *src, char const *key_path)
 Get the extarr object at specified path. More...
 
struct json_objectjson_object_path_get_any (struct json_object *src, char const *key_path)
 Get object of any type at specified path. More...
 
void json_object_free_printbuf (struct json_object *jso)
 
int64_t json_object_object_nbytes (struct json_object *const obj)
 

Variables

const char * json_number_chars = "0123456789.+-eE"
 
const char * json_hex_chars = "0123456789abcdefABCDEF"
 
static
json_object_to_json_string_fn 
json_object_object_to_json_string
 
static
json_object_to_json_string_fn 
json_object_boolean_to_json_string
 
static
json_object_to_json_string_fn 
json_object_int_to_json_string
 
static
json_object_to_json_string_fn 
json_object_double_to_json_string
 
static
json_object_to_json_string_fn 
json_object_string_to_json_string
 
static
json_object_to_json_string_fn 
json_object_array_to_json_string
 
static
json_object_to_json_string_fn 
json_object_extarr_to_json_string
 
static
json_object_to_json_string_fn 
json_object_enum_to_json_string
 
static int circbuf_idx = 0
 
static char * circbuf_retval [CIRCBUF_SIZE]
 

Function Documentation

static void json_object_generic_delete ( struct json_object jso)
static

Definition at line 174 of file json_object.c.

static struct json_object * json_object_new ( enum json_type  o_type)
static

Definition at line 185 of file json_object.c.

static int json_escape_str ( struct printbuf pb,
char *  str,
int  len 
)
static

Definition at line 101 of file json_object.c.

static void indent ( struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 300 of file json_object.c.

static int json_object_object_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 310 of file json_object.c.

static void json_object_lh_entry_free ( struct lh_entry ent)
static

Definition at line 357 of file json_object.c.

static void json_object_object_delete ( struct json_object jso)
static

Definition at line 363 of file json_object.c.

struct json_object* json_object_object_get ( struct json_object jso,
const char *  key 
)

Definition at line 415 of file json_object.c.

static int json_object_boolean_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 449 of file json_object.c.

static int json_object_int_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 487 of file json_object.c.

static int json_object_double_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 581 of file json_object.c.

int json_object_userdata_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)

Definition at line 643 of file json_object.c.

void json_object_free_userdata ( struct json_object jso,
void *  userdata 
)

Definition at line 651 of file json_object.c.

static int json_object_string_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 708 of file json_object.c.

static void json_object_string_delete ( struct json_object jso)
static

Definition at line 721 of file json_object.c.

static int json_object_array_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 775 of file json_object.c.

static void json_object_array_entry_free ( void *  data)
static

Definition at line 817 of file json_object.c.

static void json_object_array_delete ( struct json_object jso)
static

Definition at line 822 of file json_object.c.

static int json_object_extarr_to_json_string ( struct json_object jso,
struct printbuf pb,
int  level,
int  flags 
)
static

Definition at line 876 of file json_object.c.

static void json_object_extarr_delete ( struct json_object jso)
static

Definition at line 979 of file json_object.c.

Variable Documentation

json_object_to_json_string_fn json_object_object_to_json_string
static

Definition at line 58 of file json_object.c.

json_object_to_json_string_fn json_object_boolean_to_json_string
static

Definition at line 59 of file json_object.c.

json_object_to_json_string_fn json_object_int_to_json_string
static

Definition at line 60 of file json_object.c.

json_object_to_json_string_fn json_object_double_to_json_string
static

Definition at line 61 of file json_object.c.

json_object_to_json_string_fn json_object_string_to_json_string
static

Definition at line 62 of file json_object.c.

json_object_to_json_string_fn json_object_array_to_json_string
static

Definition at line 63 of file json_object.c.

json_object_to_json_string_fn json_object_extarr_to_json_string
static

Definition at line 64 of file json_object.c.

json_object_to_json_string_fn json_object_enum_to_json_string
static

Definition at line 65 of file json_object.c.