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-C Library

JSON-C is a library used within MACSio to manage data. More...

Modules

 Object Customization
 
 Reference Counting
 
 Object Introspection and Query
 
 Serialization
 
 Aggregate Types
 
 Primitive Types
 

Data Structures

struct  json_object_iter
 

Macros

#define JSON_OBJECT_DEF_HASH_ENTRIES   16
 
#define JSON_C_TO_STRING_PLAIN   0
 
#define JSON_C_TO_STRING_SPACED   (1<<0)
 
#define JSON_C_TO_STRING_PRETTY   (1<<1)
 
#define JSON_C_TO_STRING_NOZERO   (1<<2)
 
#define JSON_C_TO_STRING_UNQUOTED   (1<<3)
 
#define JSON_C_TO_STRING_NO_EXTARR_VALS   (1<<4)
 
#define JSON_C_FALSE   ((json_bool)0)
 
#define JSON_C_TRUE   ((json_bool)1)
 
#define JSON_OBJECT_DEF_HASH_ENTRIES   16
 
#define JSON_C_TO_STRING_PLAIN   0
 
#define JSON_C_TO_STRING_SPACED   (1<<0)
 
#define JSON_C_TO_STRING_PRETTY   (1<<1)
 
#define JSON_C_TO_STRING_NOZERO   (1<<2)
 
#define JSON_C_TO_STRING_UNQUOTED   (1<<3)
 
#define JSON_C_TO_STRING_NO_EXTARR_VALS   (1<<4)
 
#define JSON_C_FALSE   ((json_bool)0)
 
#define JSON_C_TRUE   ((json_bool)1)
 

Typedefs

typedef int json_bool
 
typedef struct printbuf printbuf
 
typedef struct lh_table lh_table
 
typedef struct array_list array_list
 
typedef struct json_object json_object
 
typedef struct json_object_iter json_object_iter
 
typedef struct json_tokener json_tokener
 
typedef enum json_type json_type
 
typedef enum json_extarr_type json_extarr_type
 
typedef int json_bool
 
typedef struct printbuf printbuf
 
typedef struct lh_table lh_table
 
typedef struct array_list array_list
 
typedef struct json_object json_object
 
typedef struct json_object_iter json_object_iter
 
typedef struct json_tokener json_tokener
 
typedef enum json_type json_type
 
typedef enum json_extarr_type json_extarr_type
 

Enumerations

enum  json_type {
  json_type_null, json_type_boolean, json_type_double, json_type_int,
  json_type_object, json_type_array, json_type_string, json_type_extarr,
  json_type_enum, json_type_null, json_type_boolean, json_type_double,
  json_type_int, json_type_object, json_type_array, json_type_string,
  json_type_extarr, json_type_enum
}
 
enum  json_extarr_type {
  json_extarr_type_null, json_extarr_type_bit01, json_extarr_type_byt08, json_extarr_type_int32,
  json_extarr_type_int64, json_extarr_type_flt32, json_extarr_type_flt64, json_extarr_type_null,
  json_extarr_type_bit01, json_extarr_type_byt08, json_extarr_type_int32, json_extarr_type_int64,
  json_extarr_type_flt32, json_extarr_type_flt64
}
 
enum  json_type {
  json_type_null, json_type_boolean, json_type_double, json_type_int,
  json_type_object, json_type_array, json_type_string, json_type_extarr,
  json_type_enum, json_type_null, json_type_boolean, json_type_double,
  json_type_int, json_type_object, json_type_array, json_type_string,
  json_type_extarr, json_type_enum
}
 
enum  json_extarr_type {
  json_extarr_type_null, json_extarr_type_bit01, json_extarr_type_byt08, json_extarr_type_int32,
  json_extarr_type_int64, json_extarr_type_flt32, json_extarr_type_flt64, json_extarr_type_null,
  json_extarr_type_bit01, json_extarr_type_byt08, json_extarr_type_int32, json_extarr_type_int64,
  json_extarr_type_flt32, json_extarr_type_flt64
}
 

Functions

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)
 
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 *int64_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)
 
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_name (struct json_object *enum_obj, char const *key_path, char const *val)
 
json_bool json_object_path_set_enum_choice_val (struct json_object *enum_obj, char const *key_path, int64_t 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)
 
int64_t json_object_object_nbytes (struct json_object *const obj)
 
static void json_object_enum_delete (struct json_object *jso)
 
static int json_object_enum_to_json_string (struct json_object *jso, struct printbuf *pb, int level, int flags)
 
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)
 

Variables

const char * json_number_chars
 
const char * json_hex_chars
 
json_object_delete_fn json_object_free_userdata
 
json_object_to_json_string_fn json_object_userdata_to_json_string
 
const char * json_number_chars
 
const char * json_hex_chars
 
json_object_delete_fn json_object_free_userdata
 
json_object_to_json_string_fn json_object_userdata_to_json_string
 

Detailed Description

JSON-C is a library used within MACSio to manage data.

All of the data marshalled by MACSio and its plugins is stored in an uber JSON object. In a write test, MACSio creates and updates this uber JSON object and passes it to plugins. Plugins traverse, interrogate and write out what MACSio passes to them. On the other hand, during read tests, it is the plugins that are responsible for creating the same JSON object from file data that gets passed back to MACSio to validate.

As a consequence, it is important for plugin developers to understand the structure of the JSON data object used in MACSio to represent mesh and variable data.

The easiest way to understand it is to browse an example of MACSio's uber JSON object in a web browser. However, it is very useful for your browser to have the extension necessary to render and manipulate raw JSON strings nicely. Here are some options...

Here is an example of a JSON object on a given MPI task.

This is a modified version of the JSON-C library.

The initial version was obtained from here, https://github.com/json-c/json-c/releases, numbered 0.12-20140410.

It has been modified to support HPC applications in some key ways.

These modifications have not been and most likely will not ever be pushed back to JSON-C implementors. This is primarily because many of these enhancements kinda sorta fall outside the original design scope (IMHO) of JSON in general and JSON-C in particular. In fact, the extarr and enum types break the JSON-C ascii string syntax.


Data Structure Documentation

struct json_object_iter

Definition at line 71 of file json_object.h.

Data Fields
char * key
struct json_object * val
struct lh_entry * entry

Macro Definition Documentation

#define JSON_OBJECT_DEF_HASH_ENTRIES   16

Definition at line 33 of file json_object.h.

#define JSON_C_TO_STRING_PLAIN   0

A flag for the json_object_to_json_string_ext() and json_object_to_file_ext() functions which causes the output to have no extra whitespace or formatting applied.

Definition at line 40 of file json_object.h.

#define JSON_C_TO_STRING_SPACED   (1<<0)

A flag for the json_object_to_json_string_ext() and json_object_to_file_ext() functions which causes the output to have minimal whitespace inserted to make things slightly more readable.

Definition at line 46 of file json_object.h.

#define JSON_C_TO_STRING_PRETTY   (1<<1)

A flag for the json_object_to_json_string_ext() and json_object_to_file_ext() functions which causes the output to be formatted.

See the "Two Space Tab" option at http://jsonformatter.curiousconcept.com/ for an example of the format.

Definition at line 55 of file json_object.h.

#define JSON_C_TO_STRING_NOZERO   (1<<2)

A flag to drop trailing zero for float values

Definition at line 59 of file json_object.h.

#define JSON_C_TO_STRING_UNQUOTED   (1<<3)

Definition at line 60 of file json_object.h.

#define JSON_C_TO_STRING_NO_EXTARR_VALS   (1<<4)

Definition at line 62 of file json_object.h.

#define JSON_C_FALSE   ((json_bool)0)

Definition at line 64 of file json_object.h.

#define JSON_C_TRUE   ((json_bool)1)

Definition at line 65 of file json_object.h.

#define JSON_OBJECT_DEF_HASH_ENTRIES   16

Definition at line 33 of file json_object.h.

#define JSON_C_TO_STRING_PLAIN   0

A flag for the json_object_to_json_string_ext() and json_object_to_file_ext() functions which causes the output to have no extra whitespace or formatting applied.

Definition at line 40 of file json_object.h.

#define JSON_C_TO_STRING_SPACED   (1<<0)

A flag for the json_object_to_json_string_ext() and json_object_to_file_ext() functions which causes the output to have minimal whitespace inserted to make things slightly more readable.

Definition at line 46 of file json_object.h.

#define JSON_C_TO_STRING_PRETTY   (1<<1)

A flag for the json_object_to_json_string_ext() and json_object_to_file_ext() functions which causes the output to be formatted.

See the "Two Space Tab" option at http://jsonformatter.curiousconcept.com/ for an example of the format.

Definition at line 55 of file json_object.h.

#define JSON_C_TO_STRING_NOZERO   (1<<2)

A flag to drop trailing zero for float values

Definition at line 59 of file json_object.h.

#define JSON_C_TO_STRING_UNQUOTED   (1<<3)

Definition at line 60 of file json_object.h.

#define JSON_C_TO_STRING_NO_EXTARR_VALS   (1<<4)

Definition at line 62 of file json_object.h.

#define JSON_C_FALSE   ((json_bool)0)

Definition at line 64 of file json_object.h.

#define JSON_C_TRUE   ((json_bool)1)

Definition at line 65 of file json_object.h.

Typedef Documentation

typedef int json_bool

Definition at line 80 of file json_object.h.

typedef struct printbuf printbuf

Definition at line 81 of file json_object.h.

typedef struct lh_table lh_table

Definition at line 82 of file json_object.h.

typedef struct array_list array_list

Definition at line 83 of file json_object.h.

typedef struct json_object json_object

Definition at line 84 of file json_object.h.

Definition at line 85 of file json_object.h.

typedef struct json_tokener json_tokener

Definition at line 86 of file json_object.h.

typedef enum json_type json_type
typedef int json_bool

Definition at line 80 of file json_object.h.

typedef struct printbuf printbuf

Definition at line 81 of file json_object.h.

typedef struct lh_table lh_table

Definition at line 82 of file json_object.h.

typedef struct array_list array_list

Definition at line 83 of file json_object.h.

typedef struct json_object json_object

Definition at line 84 of file json_object.h.

Definition at line 85 of file json_object.h.

typedef struct json_tokener json_tokener

Definition at line 86 of file json_object.h.

typedef enum json_type json_type

Enumeration Type Documentation

enum json_type
Enumerator
json_type_null 
json_type_boolean 
json_type_double 
json_type_int 
json_type_object 
json_type_array 
json_type_string 
json_type_extarr 
json_type_enum 
json_type_null 
json_type_boolean 
json_type_double 
json_type_int 
json_type_object 
json_type_array 
json_type_string 
json_type_extarr 
json_type_enum 

Definition at line 107 of file json_object.h.

Enumerator
json_extarr_type_null 
json_extarr_type_bit01 
json_extarr_type_byt08 
json_extarr_type_int32 
json_extarr_type_int64 
json_extarr_type_flt32 
json_extarr_type_flt64 
json_extarr_type_null 
json_extarr_type_bit01 
json_extarr_type_byt08 
json_extarr_type_int32 
json_extarr_type_int64 
json_extarr_type_flt32 
json_extarr_type_flt64 

Definition at line 120 of file json_object.h.

enum json_type
Enumerator
json_type_null 
json_type_boolean 
json_type_double 
json_type_int 
json_type_object 
json_type_array 
json_type_string 
json_type_extarr 
json_type_enum 
json_type_null 
json_type_boolean 
json_type_double 
json_type_int 
json_type_object 
json_type_array 
json_type_string 
json_type_extarr 
json_type_enum 

Definition at line 107 of file json_object.h.

Enumerator
json_extarr_type_null 
json_extarr_type_bit01 
json_extarr_type_byt08 
json_extarr_type_int32 
json_extarr_type_int64 
json_extarr_type_flt32 
json_extarr_type_flt64 
json_extarr_type_null 
json_extarr_type_bit01 
json_extarr_type_byt08 
json_extarr_type_int32 
json_extarr_type_int64 
json_extarr_type_flt32 
json_extarr_type_flt64 

Definition at line 120 of file json_object.h.

Function Documentation

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 
)

Set a custom serialization function to be used when this particular object is converted to a string by json_object_to_json_string.

If a custom serializer is already set on this object, any existing user_delete function is called before the new one is set.

If to_string_func is NULL, the other parameters are ignored and the default behaviour is reset.

The userdata parameter is optional and may be passed as NULL. If provided, it is passed to to_string_func as-is. This parameter may be NULL even if user_delete is non-NULL.

The user_delete parameter is optional and may be passed as NULL, even if the userdata parameter is non-NULL. It will be called just before the json_object is deleted, after it's reference count goes to zero (see json_object_put()). If this is not provided, it is up to the caller to free the userdata at an appropriate time. (i.e. after the json_object is deleted)

Parameters
jsothe object to customize
to_string_functhe custom serialization function
userdataan optional opaque cookie
user_deletean optional function from freeing userdata

Definition at line 220 of file json_object.c.

json_bool json_object_set_boolean ( struct json_object bool_obj,
json_bool  val 
)

Definition at line 1552 of file json_object.c.

json_bool json_object_set_enum_choice_name ( struct json_object enum_obj,
char const *  name 
)

Definition at line 1559 of file json_object.c.

json_bool json_object_set_enum_choice_val ( struct json_object enum_obj,
int64_t  val 
)

Definition at line 1574 of file json_object.c.

json_bool json_object_set_int ( struct json_object int_obj,
int32_t  val 
)

Definition at line 1581 of file json_object.c.

json_bool json_object_set_int64 ( struct json_object int64_obj,
int64_t  val 
)

Definition at line 1588 of file json_object.c.

json_bool json_object_set_double ( struct json_object double_obj,
double  val 
)

Definition at line 1595 of file json_object.c.

json_bool json_object_set_string ( struct json_object string_obj,
char const *  val 
)

Definition at line 1602 of file json_object.c.

json_bool json_object_path_set_boolean ( struct json_object obj,
char const *  key_path,
json_bool  val 
)

Definition at line 2025 of file json_object.c.

json_bool json_object_path_set_enum_choice_name ( struct json_object enum_obj,
char const *  key_path,
char const *  val 
)

Definition at line 2039 of file json_object.c.

json_bool json_object_path_set_enum_choice_val ( struct json_object enum_obj,
char const *  key_path,
int64_t  val 
)

Definition at line 2032 of file json_object.c.

json_bool json_object_path_set_int ( struct json_object obj,
char const *  key_path,
int32_t  val 
)

Definition at line 2046 of file json_object.c.

json_bool json_object_path_set_int64 ( struct json_object obj,
char const *  key_path,
int64_t  val 
)

Definition at line 2053 of file json_object.c.

json_bool json_object_path_set_double ( struct json_object obj,
char const *  key_path,
double  val 
)

Definition at line 2060 of file json_object.c.

json_bool json_object_path_set_string ( struct json_object obj,
char const *  key_path,
char const *  val 
)

Definition at line 2067 of file json_object.c.

int64_t json_object_object_nbytes ( struct json_object *const  obj)

Definition at line 2295 of file json_object.c.

static void json_object_enum_delete ( struct json_object jso)
static

Definition at line 1268 of file json_object.c.

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

Definition at line 1482 of file json_object.c.

static void* json_object_apath_get_leafobj_recurse ( struct json_object src,
char *  key_path 
)
static

Definition at line 1616 of file json_object.c.

static struct json_object* json_object_apath_get_leafobj ( struct json_object obj,
char const *  key_path 
)
static

Definition at line 1660 of file json_object.c.

Variable Documentation

const char* json_number_chars

Definition at line 52 of file json_object.c.

const char* json_hex_chars

Definition at line 53 of file json_object.c.

json_object_delete_fn json_object_free_userdata

Simply call free on the userdata pointer. Can be used with json_object_set_serializer().

Parameters
jsounused
userdatathe pointer that is passed to free().

Definition at line 243 of file json_object.h.

json_object_to_json_string_fn json_object_userdata_to_json_string

Copy the jso->_userdata string over to pb as-is. Can be used with json_object_set_serializer().

Parameters
jsoThe object whose _userdata is used.
pbThe destination buffer.
levelIgnored.
flagsIgnored.

Definition at line 254 of file json_object.h.

const char* json_number_chars

Definition at line 52 of file json_object.c.

const char* json_hex_chars

Definition at line 53 of file json_object.c.

json_object_delete_fn json_object_free_userdata

Simply call free on the userdata pointer. Can be used with json_object_set_serializer().

Parameters
jsounused
userdatathe pointer that is passed to free().

Definition at line 243 of file json_object.h.

json_object_to_json_string_fn json_object_userdata_to_json_string

Copy the jso->_userdata string over to pb as-is. Can be used with json_object_set_serializer().

Parameters
jsoThe object whose _userdata is used.
pbThe destination buffer.
levelIgnored.
flagsIgnored.

Definition at line 254 of file json_object.h.