diff --git a/doc/html/README_8md.html b/doc/html/README_8md.html new file mode 100644 index 0000000..9eb53bd --- /dev/null +++ b/doc/html/README_8md.html @@ -0,0 +1,57 @@ + + +
+ + +
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
![]() ![]() | |
![]() ![]() | |
![]() ![]() ![]() | |
![]() ![]() | |
![]() ![]() | |
![]() ![]() | |
![]() ![]() | |
![]() ![]() | |
![]() ![]() | |
![]() ![]() |
+ json-c
+ 0.14
+
+ |
+
Internal methods for working with json_type_array objects. Although this is exposed by the json_object_get_array() method, it is not recommended for direct use. +More...
++Data Structures | |
struct | array_list |
+Macros | |
#define | ARRAY_LIST_DEFAULT_SIZE 32 |
+Typedefs | |
typedef void( | array_list_free_fn )(void *data) |
typedef struct array_list | array_list |
+Functions | |
struct array_list * | array_list_new (array_list_free_fn *free_fn) |
void | array_list_free (struct array_list *al) |
void * | array_list_get_idx (struct array_list *al, size_t i) |
int | array_list_put_idx (struct array_list *al, size_t i, void *data) |
int | array_list_add (struct array_list *al, void *data) |
size_t | array_list_length (struct array_list *al) |
void | array_list_sort (struct array_list *arr, int(*compar)(const void *, const void *)) |
void * | array_list_bsearch (const void **key, struct array_list *arr, int(*compar)(const void *, const void *)) |
int | array_list_del_idx (struct array_list *arr, size_t idx, size_t count) |
Internal methods for working with json_type_array objects. Although this is exposed by the json_object_get_array() method, it is not recommended for direct use.
+#define ARRAY_LIST_DEFAULT_SIZE 32 | +
typedef struct array_list array_list | +
typedef void( array_list_free_fn)(void *data) | +
int array_list_add | +( | +struct array_list * | +al, | +
+ | + | void * | +data | +
+ | ) | ++ |
void* array_list_bsearch | +( | +const void ** | +key, | +
+ | + | struct array_list * | +arr, | +
+ | + | int(*)(const void *, const void *) | +compar | +
+ | ) | ++ |
int array_list_del_idx | +( | +struct array_list * | +arr, | +
+ | + | size_t | +idx, | +
+ | + | size_t | +count | +
+ | ) | ++ |
void array_list_free | +( | +struct array_list * | +al | ) | ++ |
void* array_list_get_idx | +( | +struct array_list * | +al, | +
+ | + | size_t | +i | +
+ | ) | ++ |
size_t array_list_length | +( | +struct array_list * | +al | ) | ++ |
+
|
+ +read | +
int array_list_put_idx | +( | +struct array_list * | +al, | +
+ | + | size_t | +i, | +
+ | + | void * | +data | +
+ | ) | ++ |
void array_list_sort | +( | +struct array_list * | +arr, | +
+ | + | int(*)(const void *, const void *) | +compar | +
+ | ) | ++ |
+ json-c
+ 0.14
+
+ |
+
|
| json_object_iterator | lh_table | |||
json_tokener |
| |||||
array_list | json_object | json_tokener_srec | ||||
| json_object_iter |
| printbuf | |||
json_object::data | lh_entry | |||||
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
++Macros | |
#define | JSON_EXPORT extern |
#define | __STRING(x) #x |
#define | JASSERT(cond) |
#define | MC_ERROR(x,...) mc_error(x, ##__VA_ARGS__) |
#define | MC_SET_DEBUG(x) |
#define | MC_GET_DEBUG() (0) |
#define | MC_SET_SYSLOG(x) |
#define | MC_DEBUG(x,...) |
#define | MC_INFO(x,...) |
+Functions | |
JSON_EXPORT void | mc_set_debug (int debug) |
JSON_EXPORT int | mc_get_debug (void) |
JSON_EXPORT void | mc_set_syslog (int syslog) |
JSON_EXPORT void | mc_debug (const char *msg,...) |
JSON_EXPORT void | mc_error (const char *msg,...) |
JSON_EXPORT void | mc_info (const char *msg,...) |
Do not use, json-c internal, may be changed or removed at any time.
+#define __STRING | +( | ++ | x | ) | +#x | +
#define JASSERT | +( | ++ | cond | ) | ++ |
#define JSON_EXPORT extern | +
#define MC_DEBUG | +( | ++ | x, | +
+ | + | + | ... | +
+ | ) | ++ |
#define MC_ERROR | +( | ++ | x, | +
+ | + | + | ... | +
+ | ) | +mc_error(x, ##__VA_ARGS__) | +
#define MC_GET_DEBUG | +( | +) | +(0) | +
#define MC_INFO | +( | ++ | x, | +
+ | + | + | ... | +
+ | ) | ++ |
#define MC_SET_DEBUG | +( | ++ | x | ) | ++ |
#define MC_SET_SYSLOG | +( | ++ | x | ) | ++ |
JSON_EXPORT void mc_debug | +( | +const char * | +msg, | +
+ | + | + | ... | +
+ | ) | ++ |
JSON_EXPORT void mc_error | +( | +const char * | +msg, | +
+ | + | + | ... | +
+ | ) | ++ |
JSON_EXPORT int mc_get_debug | +( | +void | +) | ++ |
JSON_EXPORT void mc_info | +( | +const char * | +msg, | +
+ | + | + | ... | +
+ | ) | ++ |
JSON_EXPORT void mc_set_debug | +( | +int | +debug | ) | ++ |
JSON_EXPORT void mc_set_syslog | +( | +int | +syslog | ) | ++ |
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
![]() ![]() | Internal methods for working with json_type_array objects. Although this is exposed by the json_object_get_array() method, it is not recommended for direct use |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | A convenience header that may be included instead of other individual ones |
![]() ![]() | Methods for retrieving the json-c version |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | Core json-c API. Start here, or with json_tokener.h |
![]() ![]() | An API for iterating over json_type_object objects, styled to be familiar to C++ programmers. Unlike json_object_object_foreach() and json_object_object_foreachC(), this avoids the need to expose json-c internals like lh_entry |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree |
![]() ![]() | Methods to parse an input string into a tree of json_object objects |
![]() ![]() | Basic types used in a few places in json-c, but you should include "json_object.h" instead |
![]() ![]() | Miscllaneous utility functions and macros |
![]() ![]() | Methods for walking a tree of objects |
![]() ![]() | Internal methods for working with json_type_object objects. Although this is exposed by the json_object_get_object() function and within the json_object_iter type, it is not recommended for direct use |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | Internal string buffer handing. Unless you're writing a json_object_to_json_string_fn implementation for use with json_object_set_serializer() direct use of this is not recommended |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
![]() ![]() | Do not use, json-c internal, may be changed or removed at any time |
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
+ json-c
+ 0.14
+
+ |
+
t |
+ json-c
+ 0.14
+
+ |
+
A convenience header that may be included instead of other individual ones. +More...
+A convenience header that may be included instead of other individual ones.
+
+ json-c
+ 0.14
+
+ |
+
Methods for retrieving the json-c version. +More...
++Macros | |
#define | JSON_C_MAJOR_VERSION 0 |
#define | JSON_C_MINOR_VERSION 14 |
#define | JSON_C_MICRO_VERSION 0 |
#define | JSON_C_VERSION_NUM ((JSON_C_MAJOR_VERSION << 16) | (JSON_C_MINOR_VERSION << 8) | JSON_C_MICRO_VERSION) |
#define | JSON_C_VERSION "0.14" |
#define | JSON_EXPORT extern |
+Functions | |
JSON_EXPORT const char * | json_c_version (void) |
JSON_EXPORT int | json_c_version_num (void) |
Methods for retrieving the json-c version.
+#define JSON_C_MAJOR_VERSION 0 | +
#define JSON_C_MICRO_VERSION 0 | +
#define JSON_C_MINOR_VERSION 14 | +
#define JSON_C_VERSION "0.14" | +
#define JSON_C_VERSION_NUM ((JSON_C_MAJOR_VERSION << 16) | (JSON_C_MINOR_VERSION << 8) | JSON_C_MICRO_VERSION) | +
#define JSON_EXPORT extern | +
JSON_EXPORT const char* json_c_version | +( | +void | +) | ++ |
JSON_EXPORT int json_c_version_num | +( | +void | +) | ++ |
The json-c version encoded into an int, with the low order 8 bits being the micro version, the next higher 8 bits being the minor version and the next higher 8 bits being the major version. For example, 7.12.99 would be 0x00070B63.
+
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
++Macros | |
#define | PRId64 "I64d" |
#define | SCNd64 "I64d" |
#define | PRIu64 "I64u" |
Do not use, json-c internal, may be changed or removed at any time.
+#define PRId64 "I64d" | +
#define PRIu64 "I64u" | +
#define SCNd64 "I64d" | +
+ json-c
+ 0.14
+
+ |
+
Core json-c API. Start here, or with json_tokener.h. +More...
++Macros | |
#define | THIS_FUNCTION_IS_DEPRECATED(func) func |
#define | JSON_C_CONST_FUNCTION(func) func |
#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_PRETTY_TAB (1 << 3) |
#define | JSON_C_TO_STRING_NOZERO (1 << 2) |
#define | JSON_C_TO_STRING_NOSLASHESCAPE (1 << 4) |
#define | JSON_C_OBJECT_ADD_KEY_IS_NEW (1 << 1) |
#define | JSON_C_OBJECT_KEY_IS_CONSTANT (1 << 2) |
#define | JSON_C_OPTION_GLOBAL (0) |
#define | JSON_C_OPTION_THREAD (1) |
#define | json_object_object_foreach(obj, key, val) |
#define | json_object_object_foreachC(obj, iter) |
+Typedefs | |
typedef int( | json_c_shallow_copy_fn )(json_object *src, json_object *parent, const char *key, size_t index, json_object **dst) |
Core json-c API. Start here, or with json_tokener.h.
+#define JSON_C_CONST_FUNCTION | +( | ++ | func | ) | +func | +
#define JSON_C_OBJECT_ADD_KEY_IS_NEW (1 << 1) | +
A flag for the json_object_object_add_ex function which causes the value to be added without a check if it already exists. Note: it is the responsibility of the caller to ensure that no key is added multiple times. If this is done, results are unpredictable. While this option is somewhat dangerous, it permits potentially large performance savings in code that knows for sure the key values are unique (e.g. because the code adds a well-known set of constant key values).
+ +#define JSON_C_OBJECT_KEY_IS_CONSTANT (1 << 2) | +
A flag for the json_object_object_add_ex function which flags the key as being constant memory. This means that the key will NOT be copied via strdup(), resulting in a potentially huge performance win (malloc, strdup and free are usually performance hogs). It is acceptable to use this flag for keys in non-constant memory blocks if the caller ensure that the memory holding the key lives longer than the corresponding json object. However, this is somewhat dangerous and should only be done if really justified. The general use-case for this flag is cases where the key is given as a real constant value in the function call, e.g. as in json_object_object_add_ex(obj, "ip", json, JSON_C_OBJECT_KEY_IS_CONSTANT);
+ +#define JSON_C_OPTION_GLOBAL (0) | +
Set the global value of an option, which will apply to all current and future threads that have not set a thread-local value.
+ + +#define JSON_C_OPTION_THREAD (1) | +
Set a thread-local value of an option, overriding the global value. This will fail if json-c is not compiled with threading enabled, and with the __thread specifier (or equivalent) available.
+ + +#define JSON_C_TO_STRING_NOSLASHESCAPE (1 << 4) | +
Don't escape forward slashes.
+ +#define JSON_C_TO_STRING_NOZERO (1 << 2) | +
A flag to drop trailing zero for float values
+ +#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.
+ +#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.
+ +#define JSON_C_TO_STRING_PRETTY_TAB (1 << 3) | +
A flag for the json_object_to_json_string_ext() and json_object_to_file_ext() functions which causes the output to be formatted.
+Instead of a "Two Space Tab" this gives a single tab character.
+ +#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.
+ +#define JSON_OBJECT_DEF_HASH_ENTRIES 16 | +
#define json_object_object_foreach | +( | ++ | obj, | +
+ | + | + | key, | +
+ | + | + | val | +
+ | ) | ++ |
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.
+obj | the json_object instance |
key | the local name for the char* key variable defined in the body |
val | the local name for the json_object* object variable defined in the body |
#define json_object_object_foreachC | +( | ++ | obj, | +
+ | + | + | iter | +
+ | ) | ++ |
Iterate through all keys and values of an object (ANSI C Safe)
+obj | the json_object instance |
iter | the object iterator, use type json_object_iter |
#define THIS_FUNCTION_IS_DEPRECATED | +( | ++ | func | ) | +func | +
typedef int( json_c_shallow_copy_fn)(json_object *src, json_object *parent, const char *key, size_t index, json_object **dst) | +
Perform a shallow copy of src into *dst as part of an overall json_object_deep_copy().
+If src is part of a containing object or array, parent will be non-NULL, and key or index will be provided. When shallow_copy is called *dst will be NULL, and must be non-NULL when it returns. src will never be NULL.
+If shallow_copy sets the serializer on an object, return 2 to indicate to json_object_deep_copy that it should not attempt to use the standard userdata copy function.
+JSON_C_CONST_FUNCTION | +( | +JSON_EXPORT size_t | +json_c_object_sizeofvoid | ) | ++ |
Get the sizeof (struct json_object).
+JSON_EXPORT int json_c_set_serialization_double_format | +( | +const char * | +double_format, | +
+ | + | int | +global_or_thread | +
+ | ) | ++ |
Set a global or thread-local json-c option, depending on whether JSON_C_OPTION_GLOBAL or JSON_C_OPTION_THREAD is passed. Thread-local options default to undefined, and inherit from the global value, even if the global value is changed after the thread is created. Attempting to set thread-local options when threading is not compiled in will result in an error. Be sure to check the return value.
+double_format is a "%g" printf format, such as "%.20g"
+JSON_EXPORT int json_object_array_add | +( | +struct json_object * | +obj, | +
+ | + | struct json_object * | +val | +
+ | ) | ++ |
Add an element to the end of a json_object of type json_type_array
+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 you must wrap the passed object with json_object_get
+obj | the json_object instance |
val | the json_object to be added |
+
|
+ +read | +
Binary search a sorted array for a specified key object.
+It depends on your compare function what's sufficient as a key. Usually you create some dummy object with the parameter compared in it, to identify the right item you're actually looking for.
+key | a dummy json_object with the right key |
jso | the array object we're searching |
sort_fn | the sort/compare function |
JSON_EXPORT int json_object_array_del_idx | +( | +struct json_object * | +obj, | +
+ | + | size_t | +idx, | +
+ | + | size_t | +count | +
+ | ) | ++ |
Delete an elements from a specified index in an array (a json_object of type json_type_array)
+The reference count will be decremented for each of the deleted objects. If there are no more owners of an element that is being deleted, then the value is freed. Otherwise, the reference to the value will remain in memory.
+obj | the json_object instance |
idx | the index to start deleting elements at |
count | the number of elements to delete |
+
|
+ +read | +
Get the element at specified index of the array (a json_object of type json_type_array)
+obj | the json_object instance |
idx | the index to get the element at |
JSON_EXPORT size_t json_object_array_length | +( | +const struct json_object * | +obj | ) | ++ |
Get the length of a json_object of type json_type_array
+obj | the json_object instance |
JSON_EXPORT int json_object_array_put_idx | +( | +struct json_object * | +obj, | +
+ | + | size_t | +idx, | +
+ | + | struct json_object * | +val | +
+ | ) | ++ |
Insert or replace an element at a specified index in an array (a json_object of type json_type_array)
+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 you must wrap the passed object with json_object_get
+The reference count of a replaced object will be decremented.
+The array size will be automatically be expanded to the size of the index if the index is larger than the current size.
+obj | the json_object instance |
idx | the index to insert the element at |
val | the json_object to be added |
JSON_EXPORT void json_object_array_sort | +( | +struct json_object * | +jso, | +
+ | + | int(*)(const void *, const void *) | +sort_fn | +
+ | ) | ++ |
Sorts the elements of jso of type json_type_array
+Pointers to the json_object pointers will be passed as the two arguments to sort_fn
+jso | the json_object instance |
sort_fn | a sorting function |
JSON_EXPORT int json_object_deep_copy | +( | +struct json_object * | +src, | +
+ | + | struct json_object ** | +dst, | +
+ | + | json_c_shallow_copy_fn * | +shallow_copy | +
+ | ) | ++ |
Copy the contents of the JSON object. The destination object must be initialized to NULL, to make sure this function won't overwrite an existing JSON object.
+This does roughly the same thing as json_tokener_parse(json_object_get_string(src))
.
src | source JSON object whose contents will be copied |
dst | pointer to the destination object where the contents of src ; make sure this pointer is initialized to NULL |
shallow_copy | an optional function to copy individual objects, needed when custom serializers are in use. See also json_object set_serializer. |
JSON_EXPORT int json_object_double_to_json_string | +( | +struct json_object * | +jso, | +
+ | + | struct printbuf * | +pb, | +
+ | + | int | +level, | +
+ | + | int | +flags | +
+ | ) | ++ |
Serialize a json_object of type json_type_double to a string.
+This function isn't meant to be called directly. Instead, you can set a custom format string for the serialization of this double using the following call (where "%.17g" actually is the default):
+jso | The json_type_double object that is serialized. |
pb | The destination buffer. |
level | Ignored. |
flags | Ignored. |
JSON_EXPORT int json_object_equal | +( | +struct json_object * | +obj1, | +
+ | + | struct json_object * | +obj2 | +
+ | ) | ++ |
Check if two json_object's are equal
+If the passed objects are equal 1 will be returned. Equality is defined as follows:
+obj1 | the first json_object instance |
obj2 | the second json_object instance |
+
|
+ +read | +
Increment the reference count of json_object, thereby grabbing shared ownership of obj.
+obj | the json_object instance |
+
|
+ +read | +
Get the arraylist of a json_object of type json_type_array
+obj | the json_object instance |
JSON_EXPORT json_bool json_object_get_boolean | +( | +const struct json_object * | +obj | ) | ++ |
Get the json_bool value of a json_object
+The type is coerced to a json_bool if the passed object is not a json_bool. integer and double objects will return 0 if there value is zero or 1 otherwise. If the passed object is a string it will return 1 if it has a non zero length. If any other object type is passed 1 will be returned if the object is not NULL.
+obj | the json_object instance |
JSON_EXPORT double json_object_get_double | +( | +const struct json_object * | +obj | ) | ++ |
Get the double floating point value of a json_object
+The type is coerced to a double if the passed object is not a double. integer objects will return their double conversion. Strings will be parsed as a double. If no conversion exists then 0.0 is returned and errno is set to EINVAL. null is equivalent to 0 (no error values set)
+If the value is too big to fit in a double, then the value is set to the closest infinity with errno set to ERANGE. If strings cannot be converted to their double value, then EINVAL is set & NaN is returned.
+Arrays of length 0 are interpreted as 0 (with no error flags set). Arrays of length 1 are effectively cast to the equivalent object and converted using the above rules. All other arrays set the error to EINVAL & return NaN.
+NOTE: Set errno to 0 directly before a call to this function to determine whether or not conversion was successful (it does not clear the value for you).
+obj | the json_object instance |
JSON_EXPORT int32_t json_object_get_int | +( | +const struct json_object * | +obj | ) | ++ |
Get the int value of a json_object
+The type is coerced to a int if the passed object is not a int. double objects will return their integer conversion. Strings will be parsed as an integer. If no conversion exists then 0 is returned and errno is set to EINVAL. null is equivalent to 0 (no error values set)
+Note that integers are stored internally as 64-bit values. If the value of too big or too small to fit into 32-bit, INT32_MAX or INT32_MIN are returned, respectively.
+obj | the json_object instance |
JSON_EXPORT int64_t json_object_get_int64 | +( | +const struct json_object * | +obj | ) | ++ |
Get the int value of a json_object
+The type is coerced to a int64 if the passed object is not a int64. double objects will return their int64 conversion. Strings will be parsed as an int64. If no conversion exists then 0 is returned.
+NOTE: Set errno to 0 directly before a call to this function to determine whether or not conversion was successful (it does not clear the value for you).
+obj | the json_object instance |
+
|
+ +read | +
Get the hashtable of a json_object of type json_type_object
+obj | the json_object instance |
JSON_EXPORT const char* json_object_get_string | +( | +struct json_object * | +obj | ) | ++ |
Get the string value of a json_object
+If the passed object is of type json_type_null (i.e. obj == NULL), NULL is returned.
+If the passed object of type json_type_string, the string contents are returned.
+Otherwise the JSON representation of the object is returned.
+The returned string memory is managed by the json_object and will be freed when the reference count of the json_object drops to zero.
+obj | the json_object instance |
JSON_EXPORT int json_object_get_string_len | +( | +const struct json_object * | +obj | ) | ++ |
Get the string length of a json_object
+If the passed object is not of type json_type_string then zero will be returned.
+obj | the json_object instance |
JSON_EXPORT enum json_type json_object_get_type | +( | +const struct json_object * | +obj | ) | ++ |
Get the type of the json_object. See also json_type_to_name() to turn this into a string suitable, for instance, for logging.
+obj | the json_object instance |
JSON_EXPORT uint64_t json_object_get_uint64 | +( | +const struct json_object * | +obj | ) | ++ |
Get the uint value of a json_object
+The type is coerced to a uint64 if the passed object is not a uint64. double objects will return their uint64 conversion. Strings will be parsed as an uint64. If no conversion exists then 0 is returned.
+NOTE: Set errno to 0 directly before a call to this function to determine whether or not conversion was successful (it does not clear the value for you).
+obj | the json_object instance |
JSON_EXPORT void* json_object_get_userdata | +( | +json_object * | +jso | ) | ++ |
Returns the userdata set by json_object_set_userdata() or json_object_set_serializer()
+jso | the object to return the userdata for |
JSON_EXPORT int json_object_int_inc | +( | +struct json_object * | +obj, | +
+ | + | int64_t | +val | +
+ | ) | ++ |
Increment a json_type_int object by the given amount, which may be negative.
+If the type of obj is not json_type_int then 0 is returned with no further action taken. If the addition would result in a overflow, the object value is set to INT64_MAX. If the addition would result in a underflow, the object value is set to INT64_MIN. Neither overflow nor underflow affect the return value.
+obj | the json_object instance |
val | the value to add |
JSON_EXPORT int json_object_is_type | +( | +const struct json_object * | +obj, | +
+ | + | enum json_type | +type | +
+ | ) | ++ |
Check if the json_object is of a given type
+obj | the json_object instance |
type | one of: json_type_null (i.e. obj == NULL), json_type_boolean, json_type_double, json_type_int, json_type_object, json_type_array, json_type_string |
+
|
+ +read | +
Create a new empty json_object of type json_type_array
+
+
|
+ +read | +
Create a new empty json_object of type json_type_boolean
+b | a json_bool 1 or 0 |
+
|
+ +read | +
Create a new empty json_object of type json_type_double
+d | the double |
+
|
+ +read | +
Create a new json_object of type json_type_double, using the exact serialized representation of the value.
+This allows for numbers that would otherwise get displayed inefficiently (e.g. 12.3 => "12.300000000000001") to be serialized with the more convenient form.
+Notes:
+This is used by json_tokener_parse_ex() to allow for an exact re-serialization of a parsed object.
+The userdata field is used to store the string representation, so it can't be used for other data if this function is used.
+A roughly equivalent sequence of calls, with the difference being that the serialization function won't be reset by json_object_set_double(), is:
+d | the numeric value of the double. |
ds | the string representation of the double. This will be copied. |
+
|
+ +read | +
Create a new empty json_object of type json_type_int Note that values are stored as 64-bit values internally. To ensure the full range is maintained, use json_object_new_int64 instead.
+i | the integer |
+
|
+ +read | +
Create a new empty json_object of type json_type_int
+i | the integer |
+
|
+ +read | +
This method exists only to provide a complementary function along the lines of the other json_object_new_* functions. It always returns NULL, and it is entirely acceptable to simply use NULL directly.
+ +
+
|
+ +read | +
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.
+
+
|
+ +read | +
Create a new empty json_object of type json_type_string
+A copy of the string is made and the memory is managed by the json_object
+s | the string |
+
|
+ +read | +
Create a new empty json_object of type json_type_string and allocate len characters for the new string.
+A copy of the string is made and the memory is managed by the json_object
+s | the string |
len | max length of the new string |
+
|
+ +read | +
Create a new empty json_object of type json_type_uint
+i | the integer |
JSON_EXPORT int 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.
+obj | the json_object instance |
key | the object field name (a private copy will be duplicated) |
val | a json_object or NULL member to associate with the given field |
0
is returned. On error, a negative value is returned. JSON_EXPORT int json_object_object_add_ex | +( | +struct json_object * | +obj, | +
+ | + | const char *const | +key, | +
+ | + | struct json_object *const | +val, | +
+ | + | const unsigned | +opts | +
+ | ) | ++ |
Add an object field to a json_object of type json_type_object
+The semantics are identical to json_object_object_add, except that an additional flag fields gives you more control over some detail aspects of processing. See the description of JSON_C_OBJECT_ADD_* flags for more details.
+obj | the json_object instance |
key | the object field name (a private copy will be duplicated) |
val | a json_object or NULL member to associate with the given field |
opts | process-modifying options. To specify multiple options, use arithmetic or (OPT1|OPT2) |
JSON_EXPORT 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.
+obj | the json_object instance |
key | the object field name |
+
|
+ +read | +
Get the json_object associate with a given object field. Deprecated/discouraged: used json_object_object_get_ex instead.
+This returns NULL if the field is found but its value is null, or if the field is not found, or if obj is not a json_type_object. If you need to distinguish between these cases, use json_object_object_get_ex().
+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).
+obj | the json_object instance |
key | the object field name |
JSON_EXPORT json_bool json_object_object_get_ex | +( | +const 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.
+obj | the json_object instance |
key | the object field name |
value | a pointer where to store a reference to the json_object associated with the given field name. |
It is safe to pass a NULL value.
+JSON_EXPORT int json_object_object_length | +( | +const struct json_object * | +obj | ) | ++ |
Get the size of an object in terms of the number of fields it has.
+obj | the json_object whose length to return |
JSON_EXPORT int json_object_put | +( | +struct json_object * | +obj | ) | ++ |
Decrement the reference count of json_object and free if it reaches zero. You must have ownership of obj prior to doing this or you will cause an imbalance in the reference count. An obj of NULL may be passed; in that case this call is a no-op.
+obj | the json_object instance |
JSON_EXPORT int json_object_set_boolean | +( | +struct json_object * | +obj, | +
+ | + | json_bool | +new_value | +
+ | ) | ++ |
Set the json_bool value of a json_object
+The type of obj is checked to be a json_type_boolean and 0 is returned if it is not without any further actions. If type of obj is json_type_boolean the object value is changed to new_value
+obj | the json_object instance |
new_value | the value to be set |
JSON_EXPORT int json_object_set_double | +( | +struct json_object * | +obj, | +
+ | + | double | +new_value | +
+ | ) | ++ |
Set the double value of a json_object
+The type of obj is checked to be a json_type_double and 0 is returned if it is not without any further actions. If type of obj is json_type_double the object value is changed to new_value
+If the object was created with json_object_new_double_s(), the serialization function is reset to the default and the cached serialized value is cleared.
+obj | the json_object instance |
new_value | the value to be set |
JSON_EXPORT int json_object_set_int | +( | +struct json_object * | +obj, | +
+ | + | int | +new_value | +
+ | ) | ++ |
Set the int value of a json_object
+The type of obj is checked to be a json_type_int and 0 is returned if it is not without any further actions. If type of obj is json_type_int the object value is changed to new_value
+obj | the json_object instance |
new_value | the value to be set |
JSON_EXPORT int json_object_set_int64 | +( | +struct json_object * | +obj, | +
+ | + | int64_t | +new_value | +
+ | ) | ++ |
Set the int64_t value of a json_object
+The type of obj is checked to be a json_type_int and 0 is returned if it is not without any further actions. If type of obj is json_type_int the object value is changed to new_value
+obj | the json_object instance |
new_value | the value to be set |
JSON_EXPORT 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 custom userdata 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 default behaviour is reset (but the userdata and user_delete fields are still set).
+The userdata parameter is optional and may be passed as NULL. It can be used to provide additional data for to_string_func to use. 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)
+Note that the userdata is the same as set by json_object_set_userdata(), so care must be taken not to overwrite the value when both a custom serializer and json_object_set_userdata() are used.
+jso | the object to customize |
to_string_func | the custom serialization function |
userdata | an optional opaque cookie |
user_delete | an optional function from freeing userdata |
JSON_EXPORT int json_object_set_string | +( | +json_object * | +obj, | +
+ | + | const char * | +new_value | +
+ | ) | ++ |
Set the string value of a json_object with zero terminated strings equivalent to json_object_set_string_len (obj, new_value, strlen(new_value))
+JSON_EXPORT int json_object_set_string_len | +( | +json_object * | +obj, | +
+ | + | const char * | +new_value, | +
+ | + | int | +len | +
+ | ) | ++ |
Set the string value of a json_object str
+The type of obj is checked to be a json_type_string and 0 is returned if it is not without any further actions. If type of obj is json_type_string the object value is changed to new_value
+obj | the json_object instance |
new_value | the value to be set; Since string length is given in len this need not be zero terminated |
len | the length of new_value |
JSON_EXPORT int json_object_set_uint64 | +( | +struct json_object * | +obj, | +
+ | + | uint64_t | +new_value | +
+ | ) | ++ |
Set the uint64_t value of a json_object
+The type of obj is checked to be a json_type_uint and 0 is returned if it is not without any further actions. If type of obj is json_type_uint the object value is changed to new_value
+obj | the json_object instance |
new_value | the value to be set |
JSON_EXPORT void json_object_set_userdata | +( | +json_object * | +jso, | +
+ | + | void * | +userdata, | +
+ | + | json_object_delete_fn * | +user_delete | +
+ | ) | ++ |
Set an opaque userdata value for an object
+The userdata can be retrieved using json_object_get_userdata().
+If custom userdata is already set on this object, any existing user_delete function is called before the new one is set.
+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)
+Note: Objects created by parsing strings may have custom serializers set which expect the userdata to contain specific data (due to use of json_object_new_double_s()). In this case, json_object_set_serialiser() with NULL as to_string_func should be used instead to set the userdata and reset the serializer to its default value.
+jso | the object to set the userdata for |
userdata | an optional opaque cookie |
user_delete | an optional function from freeing userdata |
JSON_EXPORT const char* json_object_to_json_string | +( | +struct json_object * | +obj | ) | ++ |
Stringify object to json format. Equivalent to json_object_to_json_string_ext(obj, JSON_C_TO_STRING_SPACED) The pointer you get is an internal of your json object. You don't have to free it, later use of json_object_put() should be sufficient. If you can not ensure there's no concurrent access to *obj use strdup().
+obj | the json_object instance |
JSON_EXPORT const char* json_object_to_json_string_ext | +( | +struct json_object * | +obj, | +
+ | + | int | +flags | +
+ | ) | ++ |
Stringify object to json format
+obj | the json_object instance |
flags | formatting options, see JSON_C_TO_STRING_PRETTY and other constants |
JSON_EXPORT const char* json_object_to_json_string_length | +( | +struct json_object * | +obj, | +
+ | + | int | +flags, | +
+ | + | size_t * | +length | +
+ | ) | ++ |
Stringify object to json format
+obj | the json_object instance |
flags | formatting options, see JSON_C_TO_STRING_PRETTY and other constants |
length | a pointer where, if not NULL, the length (without null) is stored |
JSON_EXPORT json_c_shallow_copy_fn json_c_shallow_copy_default | +
The default shallow copy implementation for use with json_object_deep_copy(). This simply calls the appropriate json_object_new_<type>() function and copies over the serializer function (_to_json_string internal field of the json_object structure) but not any _userdata or _user_delete values.
+If you're writing a custom shallow_copy function, perhaps because you're using your own custom serializer, you can call this first to create the new object before customizing it with json_object_set_serializer().
+JSON_EXPORT json_object_delete_fn json_object_free_userdata | +
Simply call free on the userdata pointer. Can be used with json_object_set_serializer().
+jso | unused |
userdata | the pointer that is passed to free(). |
JSON_EXPORT 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().
+jso | The object whose _userdata is used. |
pb | The destination buffer. |
level | Ignored. |
flags | Ignored. |
+ json-c
+ 0.14
+
+ |
+
An API for iterating over json_type_object objects, styled to be familiar to C++ programmers. Unlike json_object_object_foreach() and json_object_object_foreachC(), this avoids the need to expose json-c internals like lh_entry. +More...
++Data Structures | |
struct | json_object_iterator |
+Functions | |
JSON_EXPORT struct +json_object_iterator | json_object_iter_init_default (void) |
JSON_EXPORT struct +json_object_iterator | json_object_iter_begin (struct json_object *obj) |
JSON_EXPORT struct +json_object_iterator | json_object_iter_end (const struct json_object *obj) |
JSON_EXPORT void | json_object_iter_next (struct json_object_iterator *iter) |
JSON_EXPORT const char * | json_object_iter_peek_name (const struct json_object_iterator *iter) |
JSON_EXPORT struct json_object * | json_object_iter_peek_value (const struct json_object_iterator *iter) |
JSON_EXPORT json_bool | json_object_iter_equal (const struct json_object_iterator *iter1, const struct json_object_iterator *iter2) |
An API for iterating over json_type_object objects, styled to be familiar to C++ programmers. Unlike json_object_object_foreach() and json_object_object_foreachC(), this avoids the need to expose json-c internals like lh_entry.
+Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
+This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See COPYING for details.
+API attributes:
+
+
|
+ +read | +
Retrieves an iterator to the first pair of the JSON Object.
+obj | JSON Object instance (MUST be of type json_object) |
+
|
+ +read | +
Retrieves the iterator that represents the position beyond the last pair of the given JSON Object instance.
+obj | JSON Object instance (MUST be of type json_object) |
JSON_EXPORT json_bool json_object_iter_equal | +( | +const struct json_object_iterator * | +iter1, | +
+ | + | const struct json_object_iterator * | +iter2 | +
+ | ) | ++ |
Tests two iterators for equality. Typically used to test for end of iteration by comparing an iterator to the corresponding "end" iterator (that was derived from the same JSON Object instance).
+iter1 | Pointer to first valid, non-NULL iterator |
iter2 | POinter to second valid, non-NULL iterator |
+
|
+ +read | +
Initializes an iterator structure to a "default" value that is convenient for initializing an iterator variable to a default state (e.g., initialization list in a class' constructor).
+JSON_EXPORT void json_object_iter_next | +( | +struct json_object_iterator * | +iter | ) | ++ |
Returns an iterator to the next pair, if any
+iter | [IN/OUT] Pointer to iterator that references a name/value pair; MUST be a valid, non-end iterator. WARNING: bad things will happen if invalid or "end" iterator is passed. Upon return will contain the reference to the next pair if there is one; if there are no more pairs, will contain the "end" iterator value, which may be compared against the return value of json_object_iter_end() for the same JSON Object instance. |
JSON_EXPORT const char* json_object_iter_peek_name | +( | +const struct json_object_iterator * | +iter | ) | ++ |
Returns a const pointer to the name of the pair referenced by the given iterator.
+iter | pointer to iterator that references a name/value pair; MUST be a valid, non-end iterator. |
+
|
+ +read | +
Returns a pointer to the json-c instance representing the value of the referenced name/value pair, without altering the instance's reference count.
+iter | pointer to iterator that references a name/value pair; MUST be a valid, non-end iterator. |
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
++Data Structures | |
struct | json_object |
union | json_object::data |
+Macros | |
#define | LEN_DIRECT_STRING_DATA 32 |
+Typedefs | |
typedef void( | json_object_private_delete_fn )(struct json_object *o) |
typedef enum json_object_int_type | json_object_int_type |
+Enumerations | |
enum | json_object_int_type { json_object_int_type_int64, +json_object_int_type_uint64 + } |
+Functions | |
void | _json_c_set_last_err (const char *err_fmt,...) |
+Variables | |
const char * | json_number_chars |
const char * | json_hex_chars |
Do not use, json-c internal, may be changed or removed at any time.
+#define LEN_DIRECT_STRING_DATA 32 | +
< how many bytes are directly stored in json_object for strings?
+ +typedef enum json_object_int_type json_object_int_type | +
typedef void( json_object_private_delete_fn)(struct json_object *o) | +
enum json_object_int_type | +
void _json_c_set_last_err | +( | +const char * | +err_fmt, | +
+ | + | + | ... | +
+ | ) | ++ |
const char* json_hex_chars | +
const char* json_number_chars | +
+ json-c
+ 0.14
+
+ |
+
JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree. +More...
++Functions | |
JSON_EXPORT int | json_pointer_get (struct json_object *obj, const char *path, struct json_object **res) |
JSON_EXPORT int | json_pointer_getf (struct json_object *obj, struct json_object **res, const char *path_fmt,...) |
JSON_EXPORT int | json_pointer_set (struct json_object **obj, const char *path, struct json_object *value) |
JSON_EXPORT int | json_pointer_setf (struct json_object **obj, struct json_object *value, const char *path_fmt,...) |
JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.
+JSON_EXPORT int json_pointer_get | +( | +struct json_object * | +obj, | +
+ | + | const char * | +path, | +
+ | + | struct json_object ** | +res | +
+ | ) | ++ |
Retrieves a JSON sub-object from inside another JSON object using the JSON pointer notation as defined in RFC 6901 https://tools.ietf.org/html/rfc6901
+The returned JSON sub-object is equivalent to parsing manually the 'obj' JSON tree ; i.e. it's not a new object that is created, but rather a pointer inside the JSON tree.
+Internally, this is equivalent to doing a series of 'json_object_object_get()' and 'json_object_array_get_idx()' along the given 'path'.
+Note that the 'path' string supports 'printf()' type arguments, so, whatever is added after the 'res' param will be treated as an argument for 'path' Example: json_pointer_get(obj, "/foo/%d/%s", &res, 0, bar) This means, that you need to escape '' with '%' (just like in printf())
+obj | the json_object instance/tree from where to retrieve sub-objects |
path | a (RFC6901) string notation for the sub-object to retrieve |
res | a pointer that stores a reference to the json_object associated with the given path |
JSON_EXPORT int json_pointer_getf | +( | +struct json_object * | +obj, | +
+ | + | struct json_object ** | +res, | +
+ | + | const char * | +path_fmt, | +
+ | + | + | ... | +
+ | ) | ++ |
This is a variant of 'json_pointer_get()' that supports printf() style arguments.
+Example: json_pointer_getf(obj, res, "/foo/%d/%s", 0, bak) This also means that you need to escape '' with '%' (just like in printf())
+Please take into consideration all recommended 'printf()' format security aspects when using this function.
+obj | the json_object instance/tree to which to add a sub-object |
res | a pointer that stores a reference to the json_object associated with the given path |
path_fmt | a printf() style format for the path |
JSON_EXPORT int json_pointer_set | +( | +struct json_object ** | +obj, | +
+ | + | const char * | +path, | +
+ | + | struct json_object * | +value | +
+ | ) | ++ |
Sets JSON object 'value' in the 'obj' tree at the location specified by the 'path'. 'path' is JSON pointer notation as defined in RFC 6901 https://tools.ietf.org/html/rfc6901
+Note that 'obj' is a double pointer, mostly for the "" (empty string) case, where the entire JSON object would be replaced by 'value'. In the case of the "" path, the object at '*obj' will have it's refcount decremented with 'json_object_put()' and the 'value' object will be assigned to it.
+For other cases (JSON sub-objects) ownership of 'value' will be transferred into '*obj' via 'json_object_object_add()' & 'json_object_array_put_idx()', so the only time the refcount should be decremented for 'value' is when the return value of 'json_pointer_set()' is negative (meaning the 'value' object did not get set into '*obj').
+That also implies that 'json_pointer_set()' does not do any refcount incrementing. (Just that single decrement that was mentioned above).
+Note that the 'path' string supports 'printf()' type arguments, so, whatever is added after the 'value' param will be treated as an argument for 'path' Example: json_pointer_set(obj, "/foo/%d/%s", value, 0, bak) This means, that you need to escape '' with '%' (just like in printf())
+obj | the json_object instance/tree to which to add a sub-object |
path | a (RFC6901) string notation for the sub-object to set in the tree |
value | object to set at path |
JSON_EXPORT int json_pointer_setf | +( | +struct json_object ** | +obj, | +
+ | + | struct json_object * | +value, | +
+ | + | const char * | +path_fmt, | +
+ | + | + | ... | +
+ | ) | ++ |
This is a variant of 'json_pointer_set()' that supports printf() style arguments.
+Example: json_pointer_setf(obj, value, "/foo/%d/%s", 0, bak) This also means that you need to escape '' with '%' (just like in printf())
+Please take into consideration all recommended 'printf()' format security aspects when using this function.
+obj | the json_object instance/tree to which to add a sub-object |
value | object to set at path |
path_fmt | a printf() style format for the path |
+ json-c
+ 0.14
+
+ |
+
Methods to parse an input string into a tree of json_object objects. +More...
++Data Structures | |
struct | json_tokener_srec |
struct | json_tokener |
+Macros | |
#define | JSON_TOKENER_DEFAULT_DEPTH 32 |
#define | JSON_TOKENER_STRICT 0x01 |
#define | JSON_TOKENER_VALIDATE_UTF8 0x10 |
+Typedefs | |
typedef struct json_tokener | json_tokener |
+Functions | |
JSON_EXPORT size_t | json_tokener_get_parse_end (struct json_tokener *tok) |
JSON_EXPORT const char * | json_tokener_error_desc (enum json_tokener_error jerr) |
JSON_EXPORT enum json_tokener_error | json_tokener_get_error (struct json_tokener *tok) |
JSON_EXPORT struct json_tokener * | json_tokener_new (void) |
JSON_EXPORT struct json_tokener * | json_tokener_new_ex (int depth) |
JSON_EXPORT void | json_tokener_free (struct json_tokener *tok) |
JSON_EXPORT void | json_tokener_reset (struct json_tokener *tok) |
JSON_EXPORT struct json_object * | json_tokener_parse (const char *str) |
JSON_EXPORT struct json_object * | json_tokener_parse_verbose (const char *str, enum json_tokener_error *error) |
JSON_EXPORT void | json_tokener_set_flags (struct json_tokener *tok, int flags) |
JSON_EXPORT struct json_object * | json_tokener_parse_ex (struct json_tokener *tok, const char *str, int len) |
Methods to parse an input string into a tree of json_object objects.
+#define JSON_TOKENER_DEFAULT_DEPTH 32 | +
#define JSON_TOKENER_STRICT 0x01 | +
Be strict when parsing JSON input. Use caution with this flag as what is considered valid may become more restrictive from one release to the next, causing your code to fail on previously working input.
+This flag is not set by default.
+#define JSON_TOKENER_VALIDATE_UTF8 0x10 | +
Cause json_tokener_parse_ex() to validate that input is UTF8. If this flag is specified and validation fails, then json_tokener_get_error(tok) will return json_tokener_error_parse_utf8_string
+This flag is not set by default.
+typedef struct json_tokener json_tokener | +
enum json_tokener_error | +
enum json_tokener_state | +
JSON_EXPORT const char* json_tokener_error_desc | +( | +enum json_tokener_error | +jerr | ) | ++ |
Given an error previously returned by json_tokener_get_error(), return a human readable description of the error.
+JSON_EXPORT void json_tokener_free | +( | +struct json_tokener * | +tok | ) | ++ |
JSON_EXPORT enum json_tokener_error json_tokener_get_error | +( | +struct json_tokener * | +tok | ) | ++ |
Retrieve the error caused by the last call to json_tokener_parse_ex(), or json_tokener_success if there is no error.
+When parsing a JSON string in pieces, if the tokener is in the middle of parsing this will return json_tokener_continue.
+JSON_EXPORT size_t json_tokener_get_parse_end | +( | +struct json_tokener * | +tok | ) | ++ |
Return the offset of the byte after the last byte parsed relative to the start of the most recent string passed in to json_tokener_parse_ex(). i.e. this is where parsing would start again if the input contains another JSON object after the currently parsed one.
+Note that when multiple parse calls are issued, this is not the total number of characters parsed.
+In the past this would have been accessed as tok->char_offset.
+See json_tokener_parse_ex() for an example of how to use this.
+ +
+
|
+ +read | +
+
|
+ +read | +
+
|
+ +read | +
+
|
+ +read | +
Parse a string and return a non-NULL json_object if a valid JSON value is found. The string does not need to be a JSON object or array; it can also be a string, number or boolean value.
+A partial JSON string can be parsed. If the parsing is incomplete, NULL will be returned and json_tokener_get_error() will return json_tokener_continue. json_tokener_parse_ex() can then be called with additional bytes in str to continue the parsing.
+If json_tokener_parse_ex() returns NULL and the error is anything other than json_tokener_continue, a fatal error has occurred and parsing must be halted. Then, the tok object must not be reused until json_tokener_reset() is called.
+When a valid JSON value is parsed, a non-NULL json_object will be returned, with a reference count of one which belongs to the caller. Also, json_tokener_get_error() will return json_tokener_success. Be sure to check the type with json_object_is_type() or json_object_get_type() before using the object.
+Trailing characters after the parsed value do not automatically cause an error. It is up to the caller to decide whether to treat this as an error or to handle the additional characters, perhaps by parsing another json value starting from that point.
+Extra characters can be detected by comparing the value returned by json_tokener_get_parse_end() against the length of the last len parameter passed in.
+The tokener does not maintain an internal buffer so the caller is responsible for calling json_tokener_parse_ex with an appropriate str parameter starting with the extra characters.
+This interface is presently not 64-bit clean due to the int len argument so the function limits the maximum string size to INT32_MAX (2GB). If the function is called with len == -1 then strlen is called to check the string length is less than INT32_MAX (2GB)
+Example:
+tok | a json_tokener previously allocated with json_tokener_new() |
str | an string with any valid JSON expression, or portion of. This does not need to be null terminated. |
len | the length of str |
+
|
+ +read | +
JSON_EXPORT void json_tokener_reset | +( | +struct json_tokener * | +tok | ) | ++ |
JSON_EXPORT void json_tokener_set_flags | +( | +struct json_tokener * | +tok, | +
+ | + | int | +flags | +
+ | ) | ++ |
Set flags that control how parsing will be done.
+ +
+ json-c
+ 0.14
+
+ |
+
Basic types used in a few places in json-c, but you should include "json_object.h" instead. +More...
++Data Structures | |
struct | json_object_iter |
+Macros | |
#define | JSON_EXPORT extern |
+Typedefs | |
typedef struct json_object_iter | json_object_iter |
typedef int | json_bool |
typedef struct json_object | json_object |
The core type for all type of JSON objects handled by json-c. | |
typedef void( | json_object_delete_fn )(struct json_object *jso, void *userdata) |
typedef int( | json_object_to_json_string_fn )(struct json_object *jso, struct printbuf *pb, int level, int flags) |
typedef enum json_type | json_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 + + } |
Basic types used in a few places in json-c, but you should include "json_object.h" instead.
+#define JSON_EXPORT extern | +
typedef int json_bool | +
typedef struct json_object json_object | +
The core type for all type of JSON objects handled by json-c.
+ +typedef void( json_object_delete_fn)(struct json_object *jso, void *userdata) | +
Type of custom user delete functions. See json_object_set_serializer.
+ +typedef struct json_object_iter json_object_iter | +
typedef int( json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level, int flags) | +
Type of a custom serialization function. See json_object_set_serializer.
+ +enum json_type | +
+ json-c
+ 0.14
+
+ |
+
Miscllaneous utility functions and macros. +More...
++Macros | |
#define | json_min(a, b) ((a) < (b) ? (a) : (b)) |
#define | json_max(a, b) ((a) > (b) ? (a) : (b)) |
#define | JSON_FILE_BUF_SIZE 4096 |
+Functions | |
JSON_EXPORT struct json_object * | json_object_from_file (const char *filename) |
JSON_EXPORT struct json_object * | json_object_from_fd_ex (int fd, int depth) |
JSON_EXPORT struct json_object * | json_object_from_fd (int fd) |
JSON_EXPORT int | json_object_to_file (const char *filename, struct json_object *obj) |
JSON_EXPORT int | json_object_to_file_ext (const char *filename, struct json_object *obj, int flags) |
JSON_EXPORT int | json_object_to_fd (int fd, struct json_object *obj, int flags) |
JSON_EXPORT const char * | json_util_get_last_err (void) |
JSON_EXPORT int | json_parse_int64 (const char *buf, int64_t *retval) |
JSON_EXPORT int | json_parse_uint64 (const char *buf, uint64_t *retval) |
JSON_EXPORT int | json_parse_double (const char *buf, double *retval) |
JSON_EXPORT const char * | json_type_to_name (enum json_type o_type) |
Miscllaneous utility functions and macros.
+#define JSON_FILE_BUF_SIZE 4096 | +
#define json_max | +( | ++ | a, | +
+ | + | + | b | +
+ | ) | +((a) > (b) ? (a) : (b)) | +
#define json_min | +( | ++ | a, | +
+ | + | + | b | +
+ | ) | +((a) < (b) ? (a) : (b)) | +
+
|
+ +read | +
Create a JSON object from an already opened file descriptor, using the default maximum object depth. (JSON_TOKENER_DEFAULT_DEPTH)
+See json_object_from_fd_ex() for details.
+ +
+
|
+ +read | +
Create a JSON object from already opened file descriptor.
+This function can be helpful, when you opened the file already, e.g. when you have a temp file. Note, that the fd must be readable at the actual position, i.e. use lseek(fd, 0, SEEK_SET) before.
+The depth argument specifies the maximum object depth to pass to json_tokener_new_ex(). When depth == -1, JSON_TOKENER_DEFAULT_DEPTH is used instead.
+Returns NULL on failure. See json_util_get_last_err() for details.
+ +
+
|
+ +read | +
Read the full contents of the given file, then convert it to a json_object using json_tokener_parse().
+Returns NULL on failure. See json_util_get_last_err() for details.
+ +JSON_EXPORT int json_object_to_fd | +( | +int | +fd, | +
+ | + | struct json_object * | +obj, | +
+ | + | int | +flags | +
+ | ) | ++ |
Convert the json_object to a string and write it to the file descriptor. Handles partial writes and will keep writing until done, or an error occurs.
+fd | an open, writable file descriptor to write to |
obj | the object to serializer and write |
flags | flags to pass to json_object_to_json_string_ext() |
JSON_EXPORT int json_object_to_file | +( | +const char * | +filename, | +
+ | + | struct json_object * | +obj | +
+ | ) | ++ |
Equivalent to: json_object_to_file_ext(filename, obj, JSON_C_TO_STRING_PLAIN);
+Returns -1 if something fails. See json_util_get_last_err() for details.
+ +JSON_EXPORT int json_object_to_file_ext | +( | +const char * | +filename, | +
+ | + | struct json_object * | +obj, | +
+ | + | int | +flags | +
+ | ) | ++ |
Open and truncate the given file, creating it if necessary, then convert the json_object to a string and write it to the file.
+Returns -1 if something fails. See json_util_get_last_err() for details.
+ +JSON_EXPORT int json_parse_double | +( | +const char * | +buf, | +
+ | + | double * | +retval | +
+ | ) | ++ |
JSON_EXPORT int json_parse_int64 | +( | +const char * | +buf, | +
+ | + | int64_t * | +retval | +
+ | ) | ++ |
JSON_EXPORT int json_parse_uint64 | +( | +const char * | +buf, | +
+ | + | uint64_t * | +retval | +
+ | ) | ++ |
JSON_EXPORT const char* json_type_to_name | +( | +enum json_type | +o_type | ) | ++ |
Return a string describing the type of the object. e.g. "int", or "object", etc...
+ +JSON_EXPORT const char* json_util_get_last_err | +( | +void | +) | ++ |
Return the last error from various json-c functions, including: json_object_to_file{,ext}, json_object_to_fd() or json_object_from{file,fd}, or NULL if there is none.
+ +
+ json-c
+ 0.14
+
+ |
+
Methods for walking a tree of objects. +More...
++Macros | |
#define | JSON_C_VISIT_SECOND 0x02 |
#define | JSON_C_VISIT_RETURN_CONTINUE 0 |
#define | JSON_C_VISIT_RETURN_SKIP 7547 |
#define | JSON_C_VISIT_RETURN_POP 767 |
#define | JSON_C_VISIT_RETURN_STOP 7867 |
#define | JSON_C_VISIT_RETURN_ERROR -1 |
+Typedefs | |
typedef int( | json_c_visit_userfunc )(json_object *jso, int flags, json_object *parent_jso, const char *jso_key, size_t *jso_index, void *userarg) |
+Functions | |
JSON_EXPORT int | json_c_visit (json_object *jso, int future_flags, json_c_visit_userfunc *userfunc, void *userarg) |
Methods for walking a tree of objects.
+#define JSON_C_VISIT_RETURN_CONTINUE 0 | +
This json_c_visit_userfunc return value indicates that iteration should proceed normally.
+ +#define JSON_C_VISIT_RETURN_ERROR -1 | +
This json_c_visit_userfunc return value indicates that iteration should stop immediately, and cause json_c_visit to return an error.
+ +#define JSON_C_VISIT_RETURN_POP 767 | +
This json_c_visit_userfunc return value indicates that iteration of the fields/elements of the containing object should stop and continue "popped up" a level of the object hierarchy. For example, returning this when handling arg will result in arg3 and any other fields being skipped. The next call to userfunc will be the JSON_C_VISIT_SECOND call on "foo", followed by a userfunc call on "bar".
++{ + "foo": { + "arg1": 1, + "arg2": 2, + "arg3": 3, + ... + }, + "bar": { + ... + } +} ++
#define JSON_C_VISIT_RETURN_SKIP 7547 | +
This json_c_visit_userfunc return value indicates that iteration over the members of the current object should be skipped. If the current object isn't a container (array or object), this is no different than JSON_C_VISIT_RETURN_CONTINUE.
+ +#define JSON_C_VISIT_RETURN_STOP 7867 | +
This json_c_visit_userfunc return value indicates that iteration should stop immediately, and cause json_c_visit to return success.
+ +#define JSON_C_VISIT_SECOND 0x02 | +
Passed to json_c_visit_userfunc as one of the flags values to indicate that this is the second time a container (array or object) is being called, after all of it's members have been iterated over.
+ +typedef int( json_c_visit_userfunc)(json_object *jso, int flags, json_object *parent_jso, const char *jso_key, size_t *jso_index, void *userarg) | +
JSON_EXPORT int json_c_visit | +( | +json_object * | +jso, | +
+ | + | int | +future_flags, | +
+ | + | json_c_visit_userfunc * | +userfunc, | +
+ | + | void * | +userarg | +
+ | ) | ++ |
Visit each object in the JSON hierarchy starting at jso. For each object, userfunc is called, passing the object and userarg. If the object has a parent (i.e. anything other than jso itself) its parent will be passed as parent_jso, and either jso_key or jso_index will be set, depending on whether the parent is an object or an array.
+Nodes will be visited depth first, but containers (arrays and objects) will be visited twice, the second time with JSON_C_VISIT_SECOND set in flags.
+userfunc must return one of the defined return values, to indicate whether and how to continue visiting nodes, or one of various ways to stop.
+Returns 0 if nodes were visited successfully, even if some were intentionally skipped due to what userfunc returned. Returns <0 if an error occurred during iteration, including if userfunc returned JSON_C_VISIT_RETURN_ERROR.
+ +
+ json-c
+ 0.14
+
+ |
+
Internal methods for working with json_type_object objects. Although this is exposed by the json_object_get_object() function and within the json_object_iter type, it is not recommended for direct use. +More...
++Data Structures | |
struct | lh_entry |
struct | lh_table |
+Macros | |
#define | LH_PRIME 0x9e370001UL |
#define | LH_LOAD_FACTOR 0.66 |
#define | LH_EMPTY (void *)-1 |
#define | LH_FREED (void *)-2 |
#define | JSON_C_STR_HASH_DFLT 0 |
#define | JSON_C_STR_HASH_PERLLIKE 1 |
#define | lh_foreach(table, entry) for (entry = table->head; entry; entry = entry->next) |
#define | lh_foreach_safe(table, entry, tmp) for (entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp) |
#define | _LH_INLINE inline |
#define | _LH_UNCONST(a) ((void *)(uintptr_t)(const void *)(a)) |
#define | lh_entry_k(entry) _LH_UNCONST((entry)->k) |
#define | lh_entry_v(entry) _LH_UNCONST((entry)->v) |
+Typedefs | |
typedef void( | lh_entry_free_fn )(struct lh_entry *e) |
typedef unsigned long( | lh_hash_fn )(const void *k) |
typedef int( | lh_equal_fn )(const void *k1, const void *k2) |
typedef struct lh_table | lh_table |
+Functions | |
int | json_global_set_string_hash (const int h) |
struct lh_table * | lh_table_new (int size, lh_entry_free_fn *free_fn, lh_hash_fn *hash_fn, lh_equal_fn *equal_fn) |
struct lh_table * | lh_kchar_table_new (int size, lh_entry_free_fn *free_fn) |
struct lh_table * | lh_kptr_table_new (int size, lh_entry_free_fn *free_fn) |
void | lh_table_free (struct lh_table *t) |
int | lh_table_insert (struct lh_table *t, const void *k, const void *v) |
int | lh_table_insert_w_hash (struct lh_table *t, const void *k, const void *v, const unsigned long h, const unsigned opts) |
struct lh_entry * | lh_table_lookup_entry (struct lh_table *t, const void *k) |
struct lh_entry * | lh_table_lookup_entry_w_hash (struct lh_table *t, const void *k, const unsigned long h) |
json_bool | lh_table_lookup_ex (struct lh_table *t, const void *k, void **v) |
int | lh_table_delete_entry (struct lh_table *t, struct lh_entry *e) |
int | lh_table_delete (struct lh_table *t, const void *k) |
int | lh_table_length (struct lh_table *t) |
int | lh_table_resize (struct lh_table *t, int new_size) |
Internal methods for working with json_type_object objects. Although this is exposed by the json_object_get_object() function and within the json_object_iter type, it is not recommended for direct use.
+#define _LH_INLINE inline | +
#define _LH_UNCONST | +( | ++ | a | ) | +((void *)(uintptr_t)(const void *)(a)) | +
#define JSON_C_STR_HASH_DFLT 0 | +
default string hash function
+ +#define JSON_C_STR_HASH_PERLLIKE 1 | +
perl-like string hash function
+ +#define LH_EMPTY (void *)-1 | +
sentinel pointer value for empty slots
+ +#define lh_entry_k | +( | ++ | entry | ) | +_LH_UNCONST((entry)->k) | +
Return a non-const version of lh_entry.k.
+lh_entry.k is const to indicate and help ensure that linkhash itself doesn't modify it, but callers are allowed to do what they want with it. See also lh_entry.k_is_constant
+ +#define lh_entry_v | +( | ++ | entry | ) | +_LH_UNCONST((entry)->v) | +
Return a non-const version of lh_entry.v.
+v is const to indicate and help ensure that linkhash itself doesn't modify it, but callers are allowed to do what they want with it.
+ +#define lh_foreach | +( | ++ | table, | +
+ | + | + | entry | +
+ | ) | +for (entry = table->head; entry; entry = entry->next) | +
Convenience list iterator.
+ +#define lh_foreach_safe | +( | ++ | table, | +
+ | + | + | entry, | +
+ | + | + | tmp | +
+ | ) | +for (entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp) | +
#define LH_FREED (void *)-2 | +
sentinel pointer value for freed slots
+ +#define LH_LOAD_FACTOR 0.66 | +
The fraction of filled hash buckets until an insert will cause the table to be resized. This can range from just above 0 up to 1.0.
+ +#define LH_PRIME 0x9e370001UL | +
golden prime used in hash functions
+ +typedef void( lh_entry_free_fn)(struct lh_entry *e) | +
callback function prototypes
+ +typedef int( lh_equal_fn)(const void *k1, const void *k2) | +
callback function prototypes
+ +typedef unsigned long( lh_hash_fn)(const void *k) | +
callback function prototypes
+ +int json_global_set_string_hash | +( | +const int | +h | ) | ++ |
This function sets the hash function to be used for strings. Must be one of the JSON_C_STR_HASH_* values.
+
+
|
+ +read | +
Convenience function to create a new linkhash table with char keys.
+size | initial table size. |
free_fn | callback function used to free memory for entries. |
+
|
+ +read | +
Convenience function to create a new linkhash table with ptr keys.
+size | initial table size. |
free_fn | callback function used to free memory for entries. |
int lh_table_delete | +( | +struct lh_table * | +t, | +
+ | + | const void * | +k | +
+ | ) | ++ |
Delete a record from the table.
+If a callback free function is provided then it is called for the for the item being deleted.
+t | the table to delete from. |
k | a pointer to the key to delete. |
int lh_table_delete_entry | +( | +struct lh_table * | +t, | +
+ | + | struct lh_entry * | +e | +
+ | ) | ++ |
Delete a record from the table.
+If a callback free function is provided then it is called for the for the item being deleted.
+t | the table to delete from. |
e | a pointer to the entry to delete. |
void lh_table_free | +( | +struct lh_table * | +t | ) | ++ |
Free a linkhash table.
+If a lh_entry_free_fn callback free function was provided then it is called for all entries in the table.
+t | table to free. |
int lh_table_insert | +( | +struct lh_table * | +t, | +
+ | + | const void * | +k, | +
+ | + | const void * | +v | +
+ | ) | ++ |
Insert a record into the table.
+t | the table to insert into. |
k | a pointer to the key to insert. |
v | a pointer to the value to insert. |
0
is returned. On error, a negative value is returned. int lh_table_insert_w_hash | +( | +struct lh_table * | +t, | +
+ | + | const void * | +k, | +
+ | + | const void * | +v, | +
+ | + | const unsigned long | +h, | +
+ | + | const unsigned | +opts | +
+ | ) | ++ |
Insert a record into the table using a precalculated key hash.
+The hash h, which should be calculated with lh_get_hash() on k, is provided by the caller, to allow for optimization when multiple operations with the same key are known to be needed.
+t | the table to insert into. |
k | a pointer to the key to insert. |
v | a pointer to the value to insert. |
h | hash value of the key to insert |
opts | if set to JSON_C_OBJECT_KEY_IS_CONSTANT, sets lh_entry.k_is_constant so t's free function knows to avoid freeing the key. |
int lh_table_length | +( | +struct lh_table * | +t | ) | ++ |
+
|
+ +read | +
Lookup a record in the table.
+t | the table to lookup |
k | a pointer to the key to lookup |
+
|
+ +read | +
Lookup a record in the table using a precalculated key hash.
+The hash h, which should be calculated with lh_get_hash() on k, is provided by the caller, to allow for optimization when multiple operations with the same key are known to be needed.
+t | the table to lookup |
k | a pointer to the key to lookup |
h | hash value of the key to lookup |
json_bool lh_table_lookup_ex | +( | +struct lh_table * | +t, | +
+ | + | const void * | +k, | +
+ | + | void ** | +v | +
+ | ) | ++ |
Lookup a record in the table.
+t | the table to lookup |
k | a pointer to the key to lookup |
v | a pointer to a where to store the found value (set to NULL if it doesn't exist). |
+
|
+ +read | +
Create a new linkhash table.
+size | initial table size. The table is automatically resized although this incurs a performance penalty. |
free_fn | callback function used to free memory for entries when lh_table_free or lh_table_delete is called. If NULL is provided, then memory for keys and values must be freed by the caller. |
hash_fn | function used to hash keys. 2 standard ones are defined: lh_ptr_hash and lh_char_hash for hashing pointer values and C strings respectively. |
equal_fn | comparison function to compare keys. 2 standard ones defined: lh_ptr_hash and lh_char_hash for comparing pointer values and C strings respectively. |
int lh_table_resize | +( | +struct lh_table * | +t, | +
+ | + | int | +new_size | +
+ | ) | ++ |
Resizes the specified table.
+t | Pointer to table to resize. |
new_size | New table size. Must be positive. |
0
is returned. On error, a negative value is returned.
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
++Macros | |
#define | INFINITY (DBL_MAX + DBL_MAX) |
#define | HAVE_DECL_INFINITY |
#define | NAN (INFINITY - INFINITY) |
#define | HAVE_DECL_NAN |
Do not use, json-c internal, may be changed or removed at any time.
+#define HAVE_DECL_INFINITY | +
#define HAVE_DECL_NAN | +
#define INFINITY (DBL_MAX + DBL_MAX) | +
+ json-c
+ 0.14
+
+ |
+
Build Status
+Test Status
+JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects. It aims to conform to RFC 7159.
+git
, gcc
and cmake
Home page for json-c: https://github.com/json-c/json-c/wiki
+gcc
, clang
, or another C compilerTo generate docs you'll also need:
+doxygen>=1.8.13
If you are on a relatively modern system, you'll likely be able to install the prerequisites using your OS's packaging system.
+```sh sudo apt install git sudo apt install cmake sudo apt install doxygen # optional sudo apt install valgrind # optional ```
+json-c
GitHub repo: https://github.com/json-c/json-c
```sh $ git clone https://github.com/json-c/json-c.git $ mkdir json-c-build $ cd json-c-build $ cmake ../json-c # See CMake section below for custom arguments ```
+Note: it's also possible to put your build directory inside the json-c source directory, or even not use a separate build directory at all, but certain things might not work quite right (notably, make distcheck
)
Then:
+```sh $ make $ make test $ make USE_VALGRIND=0 test # optionally skip using valgrind $ make install ```
+The libray documentation can be generated directly from the source codes using Doxygen tool:
+```sh
+make doc google-chrome doc/html/index.html ```
+The json-c library is built with CMake, which can take a few options.
+Variable | Type | Description |
---|---|---|
CMAKE_INSTALL_PREFIX | String | The install location. |
CMAKE_BUILD_TYPE | String | Defaults to "debug" |
BUILD_SHARED_LIBS | Bool | The default build generates a dynamic (dll/so) library. Set this to OFF to create a static library instead. |
ENABLE_RDRAND | Bool | Enable RDRAND Hardware RNG Hash Seed |
ENABLE_THREADING | Bool | Enable partial threading support |
DISABLE_WERROR | Bool | Disable use of -Werror |
DISABLE_BSYMBOLIC | Bool | Disable use of -Bsymbolic-functions |
Pass these options as -D
on CMake's command-line.
```sh cmake -DBUILD_SHARED_LIBS=OFF ... ```
+Although json-c does not support fully multi-threaded access to object trees, it has some code to help make its use in threaded programs a bit safer. Currently, this is limited to using atomic operations for json_object_get() and json_object_put().
+Since this may have a performance impact, of at least 3x slower according to https://stackoverflow.com/a/11609063, it is disabled by default. You may turn it on by adjusting your cmake command with: -DENABLE_THREADING=ON
+Separately, the default hash function used for object field keys, lh_char_hash, uses a compare-and-swap operation to ensure the random seed is only generated once. Because this is a one-time operation, it is always compiled in when the compare-and-swap operation is available.
+For those familiar with the old autoconf/autogen.sh/configure method, there is a cmake-configure
wrapper script to ease the transition to cmake.
```sh mkdir build cd build ../cmake-configure –prefix=/some/install/path make ```
+cmake-configure can take a few options.
+options | Description |
---|---|
prefix=PREFIX | install architecture-independent files in PREFIX |
enable-threading | Enable code to support partly multi-threaded use |
enable-rdrand | Enable RDRAND Hardware RNG Hash Seed generation on supported x86/x64 platforms. |
enable-shared | build shared libraries [default=yes] |
enable-static | build static libraries [default=yes] |
disable-Bsymbolic | Avoid linking with -Bsymbolic-function |
disable-werror | Avoid treating compiler warnings as fatal errors |
By default, if valgrind is available running tests uses it. That can slow the tests down considerably, so to disable it use: ```sh export USE_VALGRIND=0 ```
+To run tests a separate build directory is recommended: ```sh mkdir build-test cd build-test
+VALGRIND=1 cmake .. make
+make test
+make USE_VALGRIND=0 test # optionally skip using valgrind ```
+If a test fails, check Testing/Temporary/LastTest.log
, tests/testSubDir/${testname}/${testname}.vg.out
, and other similar files. If there is insufficient output try: ```sh VERBOSE=1 make test ``` or ```sh JSONC_TEST_TRACE=1 make test ``` and check the log files again.
vcpkg
You can download and install JSON-C using the vcpkg dependency manager:
+git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +./bootstrap-vcpkg.sh +./vcpkg integrate install +vcpkg install json-c +
The JSON-C port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.
+libjson-c
If your system has pkgconfig
, then you can just add this to your makefile
:
```make CFLAGS += $(shell pkg-config –cflags json-c) LDFLAGS += $(shell pkg-config –libs json-c) ```
+Without pkgconfig
, you would do something like this:
```make JSON_C_DIR=/path/to/json_c/install CFLAGS += -I/include/json-c LDFLAGS+= -L/lib -ljson-c ```
+To use json-c you can either include json.h, or preferrably, one of the following more specific header files:
+For a full list of headers see files.html
+
+ json-c
+ 0.14
+
+ |
+
This list was created with:
+``` curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2014-04-10+created%3A<2017-12-01&sort=created&order=asc&per_page=400&page=1" > issues1.out curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2014-04-10+created%3A<2017-12-01&sort=created&order=asc&per_page=400&page=2" > issues2.out curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2014-04-10+created%3A<2017-12-01&sort=created&order=asc&per_page=400&page=3" > issues3.out jq -r '.items[] | "[" + .title + "](" + .url + ")" | tostring' issues?.out > issues.md sed -e's,^[ *(.*)](https://api.github.com/.*/([0-9].*)),Issue #\2 - \1,' -i issues.md #... manual editing ... ```
Issues and Pull Requests closed for the 0.13 release (since commit f84d9c, the 0.12 branch point, 2014-04-10)
+Issue #61 - Make json_object_object_add() indicate success or failure, test fix \ Issue #113 - Build fixes (make dist and make distcheck) \ Issue #124 - Fixing build \ Issue #125 - Fix compile error(variable size set but not used) on g++4.6 \ Issue #126 - Removed unused size variable. \ Issue #127 - remove unused size
variable \ Issue #128 - Remove unused variable from json_tokenizer.c \ Issue #130 - Failed to compile under Ubuntu 13.10 32bit \ Issue #131 - undefined symbol: __sync_val_compare_and_swap_4 \ Issue #132 - Remove unused variable 'size' \ Issue #133 - Update and rename README to README.md \ Issue #134 - Must remove variable size... \ Issue #135 - bits.h uses removed json_tokener_errors[error] \ Issue #136 - Error when running make check \ Issue #137 - config.h.in should not be in git \ Issue #138 - Can't build on RHEL 6.5 due to dependency on automake-1.14 \ Issue #140 - Code bug in random_test.c evaluating same expression twice \ Issue #141 - Removed duplicate check in random_seed test - bug #140 \ Issue #142 - Please undeprecate json_object_object_get \ Issue #144 - Introduce json_object_from_fd \ Issue #145 - Handle % character properly \ Issue #146 - TAGS rename \ Issue #148 - Bump the soname \ Issue #149 - SONAME bump \ Issue #150 - Fix build using MinGW. \ Issue #151 - Remove json_type enum trailing comma \ Issue #152 - error while compiling json-c library version 0.11 \ Issue #153 - improve doc for json_object_to_json_string() \ Issue #154 - double precision \ Issue #155 - add bsearch for arrays \ Issue #156 - Remove trailing whitespaces \ Issue #157 - JSON-C shall not exit on calloc fail. \ Issue #158 - while using json-c 0.11, I am facing strange crash issue in json_object_put. \ Issue #159 - json_tokener.c compile error \ Issue #160 - missing header file on windows?? \ Issue #161 - Is there a way to append to file? \ Issue #162 - json_util: add directory check for POSIX distros \ Issue #163 - Fix Win32 build problems \ Issue #164 - made it compile and link on Widnows (as static library) \ Issue #165 - json_object_to_json_string_ext length \ Issue #167 - Can't build on Windows with Visual Studio 2010 \ Issue #168 - Tightening the number parsing algorithm \ Issue #169 - Doesn't compile on ubuntu 14.04, 64bit \ Issue #170 - Generated files in repository \ Issue #171 - Update configuration for VS2010 and win64 \ Issue #172 - Adding support for parsing octal numbers \ Issue #173 - json_parse_int64 doesn't work correctly at illumos \ Issue #174 - Adding JSON_C_TO_STRING_PRETTY_TAB flag \ Issue #175 - make check fails 4 tests with overflows when built with ASAN \ Issue #176 - Possible to delete an array element at a given idx ? \ Issue #177 - Fix compiler warnings \ Issue #178 - Unable to compile on CentOS5 \ Issue #179 - Added array_list_del_idx and json_object_array_del_idx \ Issue #180 - Enable silent build by default \ Issue #181 - json_tokener_parse_ex accepts invalid JSON \ Issue #182 - Link against libm when needed \ Issue #183 - Apply compile warning fix to master branch \ Issue #184 - Use only GCC-specific flags when compiling with GCC \ Issue #185 - compile error \ Issue #186 - Syntax error \ Issue #187 - array_list_get_idx and negative indexes. \ Issue #188 - json_object_object_foreach warnings \ Issue #189 - noisy json_object_from_file: error opening file \ Issue #190 - warning: initialization discards const qualifier from pointer target type [enabled by default] \ Issue #192 - json_tokener_parse accepts invalid JSON {"key": "value" , } \ Issue #193 - Make serialization format of doubles configurable \ Issue #194 - Add utility function for comparing json_objects \ Issue #195 - Call uselocale instead of setlocale \ Issue #196 - Performance improvements \ Issue #197 - Time for a new release? \ Issue #198 - Fix possible memory leak and remove superfluous NULL checks before free() \ Issue #199 - Fix build in Visual Studio \ Issue #200 - Add build scripts for CI platforms \ Issue #201 - disable forward-slash escaping? \ Issue #202 - Array with objects support \ Issue #203 - Add source position/coordinates to API \ Issue #204 - json-c/json.h not found \ Issue #205 - json-c Compiled with Visual Studios \ Issue #206 - what do i use in place of json_object_object_get? \ Issue #207 - Add support for property pairs directly added to arrays \ Issue #208 - Performance enhancements (mainly) to json_object_to_json_string() \ Issue #209 - fix regression from 2d549662be832da838aa063da2efa78ee3b99668 \ Issue #210 - Use size_t for arrays \ Issue #211 - Atomic updates for the refcount \ Issue #212 - Refcount doesn't work between threads \ Issue #213 - fix to compile with microsoft visual c++ 2010 \ Issue #214 - Some non-GNU systems support __sync_val_compare_and_swap \ Issue #215 - Build json-c for window 64 bit. \ Issue #216 - configure: check realloc with AC_CHECK_FUNCS() to fix cross-compilation. \ Issue #217 - Checking for functions in float.h \ Issue #218 - Use a macro to indicate C99 to the compiler \ Issue #219 - Fix various potential null ptr deref and int32 overflows \ Issue #220 - Add utility function for comparing json_objects \ Issue #221 - JSON_C_TO_STRING_NOSLASHESCAPE works incorrectly \ Issue #222 - Fix issue #221: JSON_C_TO_STRING_NOSLASHESCAPE works incorrectly \ Issue #223 - Clarify json_object_get_string documentation of NULL handling & return \ Issue #224 - json_tokener.c - all warnings being treated as errors \ Issue #225 - Hi, will you support clib as a "registry"? \ Issue #227 - Bump SOVERSION to 3 \ Issue #228 - avoid double slashes from json \ Issue #229 - configure fails: checking size of size_t... configure: error: cannot determine a size for size_t \ Issue #230 - Use stdint.h to check for size_t size \ Issue #231 - Fix size_t size check for first-time builds \ Issue #232 - tests/tests1: fix printf format for size_t arguments \ Issue #233 - Include stddef.h in json_object.h \ Issue #234 - Add public API to use userdata independently of custom serializer \ Issue #235 - Undefined symbols Error for architecture x86_64 on Mac \ Issue #236 - Building a project which uses json-c with flag -Wcast-qual causes compilation errors \ Issue #237 - handle escaped utf-8 \ Issue #238 - linkhash.c: optimised the table_free path \ Issue #239 - initialize null terminator of new printbuf \ Issue #240 - Compile error: Variable set but not used \ Issue #241 - getting error in date string 19\/07\/2016, fixed for error 19/07/2016 \ Issue #242 - json_tokener_parse error \ Issue #243 - Fix #165 \ Issue #244 - Error while compiling source from RHEL5, could you please help me to fix this \ Issue #245 - json-c compile in window xp \ Issue #246 - Mac: uselocale failed to build \ Issue #247 - json_object_array_del_idx function has segment fault error? \ Issue #248 - Minor changes in C source code \ Issue #249 - Improving README \ Issue #250 - Improving .gitignore \ Issue #251 - Adding a file for EditorConfig \ Issue #252 - Very minor changes not related to C source code \ Issue #253 - Adding a test with cppcheck for Travis CI \ Issue #254 - Very minor changes to some tests \ Issue #255 - Minor changes in C source code \ Issue #256 - Mailing list dead? \ Issue #257 - Defining a coding style \ Issue #258 - Enable CI services \ Issue #259 - Fails to parse valid json \ Issue #260 - Adding an object to itself \ Issue #261 - Lack of proper documentation \ Issue #262 - Add Cmakefile and fix compiler warning. \ Issue #263 - Compiler Warnings with VS2015 \ Issue #264 - successed in simple test while failed in my project \ Issue #265 - Conformance report for reference \ Issue #266 - crash perhaps related to reference counting \ Issue #267 - Removes me as Win32 maintainer, because I'm not. \ Issue #268 - Documentation of json_object_to_json_string gives no information about memory management \ Issue #269 - json_object_<type>_set(json_object *o,<type> value) API for value setting in json object private structure \ Issue #270 - new API json_object_new_double_f(doubel d,const char * fmt); \ Issue #271 - Cannot compile using CMake on macOS \ Issue #273 - fixed wrong object name in json_object_all_values_equal \ Issue #274 - Support for 64 bit pointers on Windows \ Issue #275 - Out-of-bounds read in json_tokener_parse_ex \ Issue #276 - ./configure for centos release 6.7(final) failure \ Issue #277 - Json object set xxx \ Issue #278 - Serialization of double with no fractional component drops trailing zero \ Issue #279 - Segmentation fault in array_list_length() \ Issue #280 - Should json_object_array_get_idx check whether input obj is array? \ Issue #281 - how to pretty print json-c? \ Issue #282 - ignore temporary files \ Issue #283 - json_pointer: add first revision based on RFC 6901 \ Issue #284 - Resusing json_tokener object \ Issue #285 - Revert "compat/strdup.h: move common compat check for strdup() to own \
+<a href="https://github.com/json-c/json-c/issues/286">Issue #286</a> - json_tokener_parse_ex() returns json_tokener_continue on zero-length string \
+<a href="https://github.com/json-c/json-c/issues/287">Issue #287</a> - json_pointer: extend setter & getter with printf() style arguments \
+<a href="https://github.com/json-c/json-c/issues/288">Issue #288</a> - Fix _GNU_SOURCE define for vasprintf \
+<a href="https://github.com/json-c/json-c/issues/289">Issue #289</a> - bugfix: floating point representaion without fractional part \
+<a href="https://github.com/json-c/json-c/issues/290">Issue #290</a> - duplicate an json_object \
+<a href="https://github.com/json-c/json-c/issues/291">Issue #291</a> - isspace assert error \
+<a href="https://github.com/json-c/json-c/issues/292">Issue #292</a> - configure error "./configure: line 13121: syntax error near unexpected token `-Wall'" \
+<a href="https://github.com/json-c/json-c/issues/293">Issue #293</a> - how to make with bitcode for ios \
+<a href="https://github.com/json-c/json-c/issues/294">Issue #294</a> - Adding UTF-8 validation. Fixes #122 \
+<a href="https://github.com/json-c/json-c/issues/295">Issue #295</a> - cross compile w/ mingw \
+<a href="https://github.com/json-c/json-c/issues/296">Issue #296</a> - Missing functions header in json_object.h \
+<a href="https://github.com/json-c/json-c/issues/297">Issue #297</a> - could not parse string to Json object? Like string str=\"helloworld;E\test\log\;end" \ Issue #298 - Building using CMake doesn't work \ Issue #299 - Improve json_object -> string performance \ Issue #300 - Running tests with MinGW build \ Issue #301 - How to deep copy json_object in C++ ? \ Issue #302 - json_tokener_parse_ex doesn't parse JSON values \ Issue #303 - fix doc in tokener header file \ Issue #304 - (.text+0x72846): undefined reference to `is_error' \ Issue #305 - Fix compilation without C-99 option \ Issue #306 - ./configure: line 12748 -error=deprecated-declarations \ Issue #307 - Memory leak in json_tokener_parse \ Issue #308 - AM_PROG_LIBTOOL not found on Linux \ Issue #309 - GCC 7 reports various -Wimplicit-fallthrough= errors \ Issue #310 - Add FALLTHRU comment to handle GCC7 warnings. \ Issue #311 - Fix error C3688 when compiling on Visual Studio 2015 \ Issue #312 - Fix CMake Build process improved for MinGW and MSYS2 \ Issue #313 - VERBOSE=1 make check; tests/test_util_file.test.c and tests/test_util_file.expected out of sync \ Issue #315 - Passing -1 to json_tokener_parse_ex is possibly unsafe \ Issue #316 - Memory Returned by json_object_to_json_string not freed \ Issue #317 - json_object_get_string gives segmentation error \ Issue #318 - PVS-Studio static analyzer analyze results \ Issue #319 - Windows: Fix dynamic library build with Visual Studio \ Issue #320 - Can't compile in Mac OS X El Capitan \ Issue #321 - build,cmake: fix vasprintf implicit definition and generate both static & shared libs \ Issue #322 - can not link with libjson-c.a \ Issue #323 - implicit fallthrough detected by gcc 7.1 \ Issue #324 - JsonPath like function? \ Issue #325 - Fix stack buffer overflow in json_object_double_to_json_string_format() \ Issue #327 - why json-c so hard to compile \ Issue #328 - json_object: implement json_object_deep_copy() function \ Issue #329 - build,cmake: build,cmake: rename libjson-c-static.a to libjson-c.a \ Issue #330 - tests: symlink basic tests to a single file that has the common code \ Issue #331 - Safe use of snprintf() / vsnprintf() for Visual studio, and thread-safety fix \ Issue #332 - Valgrind: invalid read after json_object_array_del_idx. \ Issue #333 - Replace obsolete AM_PROG_LIBTOOL \ Issue #335 - README.md: show build status tag from travis-ci.org \ Issue #336 - tests: fix tests in travis-ci.org \ Issue #337 - Synchronize "potentially racy" random seed in lh_char_hash() \ Issue #338 - implement json_object_int_inc(json_object *, int64_t) \ Issue #339 - Json schema validation \ Issue #340 - strerror_override: add extern "C" and JSON_EXPORT specifiers for Visual C++ compilers \ Issue #341 - character "/" parse as "\/" \ Issue #342 - No such file or directory "/usr/include/json.h" \ Issue #343 - Can't parse json \ Issue #344 - Fix Mingw build \ Issue #345 - Fix make dist and make distcheck \ Issue #346 - Clamp double to int32 when narrowing in json_object_get_int. \ Issue #347 - MSVC linker error json_c_strerror \ Issue #348 - why \ Issue #349 - missing
is missing? \ Issue #350 - stderror-override and disable-shared \ Issue #351 - SIZE_T_MAX redefined from limits.h \ Issue #352 - INSTALL
overrides an automake script. \ Issue #353 - Documentation issues \ Issue #354 - Fixes #351 #352 #353 \ Issue #355 - 1.make it can been compiled with Visual Studio 2010 by modify the CMakeList.txt and others \ Issue #356 - VS2008 test test_util_file.cpp err! \ Issue #357 - __json_c_strerror incompatibility with link-time optimization \ Issue #358 - make issue \ Issue #359 - update CMakeLists.txt for compile with visual studio at least 2010 \ Issue #360 - Use strtoll() to parse ints \ Issue #361 - Fix double to int cast overflow in json_object_get_int64. \ Issue #362 - CMake Package Config \ Issue #363 - Issue #338, add json_object_add_int functions \ Issue #364 - Cmake is Errir \ Issue #365 - added fallthrough for gcc7 \ Issue #366 - how to check the json string,crash! \ Issue #367 - Is json-c support "redirect" semantic? \ Issue #368 - Add examples \ Issue #369 - How to build json-c library for android? \ Issue #370 - Compiling using clang-cl \ Issue #371 - Invalid parsing for Infinity with json-c 0.12 \ Issue #372 - Json-c 0.12: Fixed Infinity bug \ Issue #373 - build: fix build on appveyor CI \ Issue #374 - Undefined symbols for architecture x86_64: \ Issue #375 - what would happened when json_object_object_add add the same key \ Issue #376 - Eclipse error \ Issue #377 - on gcc 7.2.0 on my linux distribution with json-c 2013-04-02 source \ Issue #378 - Eclipse: library (libjson-c) not found, but configured \ Issue #379 - error: this statement may fall through [-Werror=implicit-fallthrough=] \ Issue #380 - Build on Windows \ Issue #381 - Fix makedist \ Issue #382 - Memory leak for json_tokener_parse_ex for version 0.12.1 \ Issue #383 - Fix a compiler warning. \ Issue #384 - Fix a VS 2015 compiler warnings. \
This list was created with:
+``` curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2017-12-07+created%3A<2020-04-17&sort=created&order=asc&per_page=400&page=1" > issues1.out curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2017-12-07+created%3A<2020-04-17&sort=created&order=asc&per_page=400&page=2" > issues2.out curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2017-12-07+created%3A<2020-04-17&sort=created&order=asc&per_page=400&page=3" > issues3.out jq -r '.items[] | "[" + .title + "](" + .url + ")" | tostring' issues?.out > issues.md sed -e's,^[ *(.*)](https://api.github.com/.*/([0-9].*)),Issue #\2 - \1,' -i issues.md #... manual editing ... ```
Issues and Pull Requests closed for the 0.14 release (since commit d582d3a(2017-12-07) to a911439(2020-04-17))
+Issue #122 - Add utf-8 validation when parsing strings. \ Issue #139 - json_object_from_file cannot accept max_depth \ Issue #143 - RFE / enhancement for full 64-bit signed/unsigned support \ Issue #147 - Please introduce soname bump if API changed \ Issue #166 - Need a way to specify nesting depth when opening JSON file \ Issue #226 - There is no json_object_new_null() \ Issue #314 - new release ? \ Issue #326 - Please extend api json_object_get_uint64 \ Issue #334 - Switch json-c builds to use CMake \ Issue #386 - Makefile: Add ACLOCAL_AMFLAGS \ Issue #387 - doc: Use other doxygen feature to specify mainpage \ Issue #388 - json_object: Add size_t json_object_sizeof() \ Issue #389 - json_object: Avoid double free (and thus a segfault) when ref_count gets < 0 \ Issue #390 - json_object: Add const size_t json_c_object_sizeof() \ Issue #391 - Fix non-GNUC define for JSON_C_CONST_FUNCTION \ Issue #392 - json_object: Avoid invalid free (and thus a segfault) when ref_count gets < 0 \ Issue #393 - json_object_private: Use unsigned 32-bit integer type for refcount \ Issue #394 - Problem serializing double \ Issue #395 - Key gets modified if it contains "\" \ Issue #396 - Build failure with no threads uClibc toolchain \ Issue #397 - update json object with key. \ Issue #398 - Build failed. \ Issue #399 - Avoid uninitialized variable warnings \ Issue #400 - How to generate static lib (.a) \ Issue #401 - Warnings with Valgrind \ Issue #402 - Add fuzzers from OSS-Fuzz \ Issue #403 - Segmentation fault when double quotes is used \ Issue #404 - valgrind: memory leak \ Issue #405 - Missing API to determine an object is empty \ Issue #406 - Undefine NDEBUG for tests \ Issue #407 - json_tokener_parse is crash \ Issue #408 - bug in array_list_del_idx when array_list_length()==1 \ Issue #410 - Fixed typos \ Issue #411 - Crash- signal SIGSEGV, Segmentation fault. ../sysdeps/x86_64/strlen.S: No such file or directory. \ Issue #412 - json_type changes during inter process communication. \ Issue #413 - how to read object of type json_object *
in c++ \ Issue #414 - [Question] How JSON-c stores the serialized data in memory? \ Issue #415 - Resolve windows name conflict \ Issue #416 - segmentation fault in json_tokener_parse \ Issue #417 - json_tokener_parse json_object_object_get_ex with string value which is json string \ Issue #418 - json_object_from_* return value documented incorrectly \ Issue #419 - Suggestion: document (and define) that json_object_put() accepts NULL pointer to object \ Issue #420 - arraylist: Fixed names of parameters for callback function \ Issue #421 - install json_object_iterator.h header file \ Issue #422 - json_object_get_double() does not set errno when there is no valid conversion \ Issue #423 - memory leak \ Issue #424 - Parse string contains "\" or "/" errors \ Issue #425 - what this is? \ Issue #426 - __deprecated not supported on clang. \ Issue #427 - CMake: builds involving this target will not be correct \ Issue #430 - json_object_object_del() and Segmentation fault \ Issue #431 - cmake: Bump required version \ Issue #432 - The real CMake support. \ Issue #433 - The real CMake support. \ Issue #434 - The real CMake support \ Issue #435 - json_object_object_del() segmentation fault \ Issue #436 - Improve pkgconfig setting \ Issue #437 - Bad link in README.md \ Issue #438 - Bad link in README.html \ Issue #439 - reserved identifier violation \ Issue #440 - Use of angle brackets around file names for include statements \ Issue #441 - fix c flag loss during cmake building \ Issue #442 - error in configure file \ Issue #443 - remove pretty spaces when using pretty tabs \ Issue #444 - Document refcount of json_tokener_parse_ex return \ Issue #445 - Add missing "make check" target to cmake config \ Issue #446 - Forward slashes get escaped \ Issue #448 - Buffer overflow in json-c \ Issue #449 - Need of json_type_int64 returned by json_object_get_type() \ Issue #450 - Allow use json-c cmake as subproject \ Issue #452 - Update README.md \ Issue #453 - Fixed misalignment in JSON string due to space after
+ being printed... \ Issue #454 - json_object_private: save 8 bytes in struct json_object in 64-bit arc… \ Issue #455 - index.html:fix dead link \ Issue #456 - STYLE.txt:remove executable permissions \ Issue #457 - .gitignore:add build directory \ Issue #458 - README.md:fix dead "file.html" link \ Issue #459 - README.html:fix link to Doxygen docs, remove WIN32 link \ Issue #460 - No docs for json_object_new_string_len() \ Issue #461 - json_object.c:set errno in json_object_get_double() \ Issue #462 - json_object.h:document json_object_new_string_len() \ Issue #463 - please check newlocale api first argument valuse. \ Issue #465 - CMakeLists.txt doesn't contain json_object_iterator.h which json.h includes \ Issue #466 - configure:3610: error: C compiler cannot create executables \ Issue #467 - Fix compiler warnings \ Issue #468 - Fix compiler warnings \ Issue #469 - Build under alpine with pecl install & docker-php-ext-enable? \ Issue #470 - cfuhash_foreach_remove doesn't upate cfuhash_num_entries \ Issue #472 - Segmentation fault in json_object_iter_begin \ Issue #473 - Convert ChangeLog to valid UTF-8 encoding. \ Issue #474 - Installation directories empty with CMake in pkg-config. \ Issue #475 - improvement proposal for json_object_object_foreach \ Issue #477 - Hang/Crash with large strings \ Issue #478 - json_object_get_string_len returns 0 when value is number \ Issue #479 - I want to use it in iOS or Android but I can't compile \ Issue #480 - json-c-0.12.1 failed making from source code \ Issue #481 - error while loading shared libraries: libjson-c.so.4 \ Issue #482 - Error "double free or corruption" after free() \ Issue #483 - compatible with rarely-used Chinese characters in GBK charset \ Issue #485 - Install CMake module files \ Issue #486 - In the case of negative double value, it is formatted without including ".0" \ Issue #488 - Some APIs are not exported when built as shared lib on Win32 \ Issue #489 - Don't use -Werror by default \ Issue #490 - do not compile with -Werror by default \ Issue #491 - build: add option –disable-werror to configure \ Issue #492 - lack some quick usage in readme \ Issue #494 - Code generator? \ Issue #495 - README.md:fix 2 typos \ Issue #496 - json_pointer.h:suggest minor grammar improvement for pointer doc \ Issue #497 - add common header for all tests \ Issue #498 - double_serializer_test fails (with valgrind) \ Issue #499 - .travis.yml:test on more recent clang and gcc versions \ Issue #500 - test/Makefile.am:add missing deps for test1 and test2 \ Issue #501 - undefine NDEBUG for tests \ Issue #502 - configure error \ Issue #503 - json-c retuns OK when Invalid json string is passed \ Issue #504 - json_object_put coredump \ Issue #505 - Add vcpkg installation instructions \ Issue #506 - Cannot parse more than one object \ Issue #509 - Sometimes a double value is not serialized \ Issue #510 - Bump so-name and improve CMake \ Issue #511 - Reduce lines for better optimization \ Issue #512 - Properly append to CMAKE_C_FLAGS string \ Issue #513 - What does userdata
means?And what is the case we can use it? \ Issue #514 - Json c 0.13 \ Issue #515 - Mies suomesta fixes segfaults and logic errors \ Issue #516 - Lja slight mods \ Issue #518 - Escape character "\\003\", get unexpected value \ Issue #519 - Add test case obj token \ Issue #520 - Adding type uint64 \ Issue #521 - build cmake windows 10 \ Issue #522 - update json_visit testcase \ Issue #523 - update tsetcase for tokener_c \ Issue #524 - Increase coverage \ Issue #525 - update pointer test case \ Issue #526 - Increased the test coverage of printbuf.c 82% to 92%. \ Issue #527 - Arraylist testcase \ Issue #528 - Solve issue #108. Skip while parsing. \ Issue #529 - Increased the test coverage of json_c_version.c 0% to 100%. \ Issue #530 - validate utf-8 string before parse \ Issue #531 - validate utf-8 string \ Issue #532 - json_object_object_get_ex returning the original object \ Issue #533 - Fix "make check" \ Issue #535 - short string optimization: excessive array length \ Issue #536 - add json_object_new_null() \ Issue #538 - update shortstring and arraylist parameters \ Issue #539 - double serializes to the old value after set_double \ Issue #541 - add coveralls auto tool to json-c \ Issue #542 - add uint64 data to json-c \ Issue #543 - Readme \ Issue #544 - Increase distcheck target in cmake \ Issue #545 - add doc target in cmake \ Issue #546 - Add uninstall target in cmake \ Issue #547 - modify json-c default build type, and fix up the assert() errors in t… \ Issue #548 - Solve some problems about cmake build type (debug/release) \ Issue #549 - lib installation issues \ Issue #550 - Format codes with clang-format tool? \ Issue #551 - Allow hexadecimal number format convention parsing \ Issue #553 - Fix/clang ubsan \ Issue #554 - RFC 8259 compatibility mode \ Issue #555 - Format json-c with clang-format tool \ Issue #556 - Fixes various Wreturn-type and Wimplicit-fallthrough errors on Mingw-w64 \ Issue #557 - Add option in CMAKE to not build documentation \ Issue #558 - modify the doc target message \ Issue #559 - json_c_visit() not exported on Windows \ Issue #560 - error: implicit declaration of function '_strtoi64' \ Issue #561 - add the badge in README.md and test the coveralls \ Issue #562 - Bugfix and testcases supplements \ Issue #563 - Changed order of calloc args to match stdlib \ Issue #564 - Remove autogenerated files \ Issue #565 - test the CI and ignore this PR \ Issue #566 - add the json_types.h to Makefile.am \ Issue #567 - Install json_types.h with autotools build as well. \ Issue #568 - Adding better support to MinGW \ Issue #569 - Handling of -Bsymbolic-function in CMakeLists.txt is deficient \ Issue #571 - CMake: Bump SONAME to 5. \ Issue #572 - Small fixes to CMakeLists \ Issue #573 - Fix coveralls submission. \ Issue #574 - autogen.sh missing from repository \ Issue #575 - Small cosmetics. \ Issue #576 - Test coverage for json_c_version. \ Issue #577 - Be verbose on failing json_c_version test. \ Issue #578 - CMake: Install pkgconfig file in proper location by default \ Issue #579 - Enforce strict prototypes. \ Issue #580 - Fix CMake tests for enforced strict prototypes. \ Issue #581 - CMakeLists: do not enforce strict prototypes on Windows. \
+ json-c
+ 0.14
+
+ |
+
![]() | |
![]() | |
![]() |
+ json-c
+ 0.14
+
+ |
+
Internal string buffer handing. Unless you're writing a json_object_to_json_string_fn implementation for use with json_object_set_serializer() direct use of this is not recommended. +More...
++Data Structures | |
struct | printbuf |
+Macros | |
#define | JSON_EXPORT extern |
#define | printbuf_memappend_fast(p, bufptr, bufsize) |
#define | printbuf_length(p) ((p)->bpos) |
#define | _printbuf_check_literal(mystr) ("" mystr) |
#define | printbuf_strappend(pb, str) printbuf_memappend((pb), _printbuf_check_literal(str), sizeof(str) - 1) |
+Typedefs | |
typedef struct printbuf | printbuf |
+Functions | |
JSON_EXPORT struct printbuf * | printbuf_new (void) |
JSON_EXPORT int | printbuf_memappend (struct printbuf *p, const char *buf, int size) |
JSON_EXPORT int | printbuf_memset (struct printbuf *pb, int offset, int charvalue, int len) |
JSON_EXPORT int | sprintbuf (struct printbuf *p, const char *msg,...) |
JSON_EXPORT void | printbuf_reset (struct printbuf *p) |
JSON_EXPORT void | printbuf_free (struct printbuf *p) |
Internal string buffer handing. Unless you're writing a json_object_to_json_string_fn implementation for use with json_object_set_serializer() direct use of this is not recommended.
+#define _printbuf_check_literal | +( | ++ | mystr | ) | +("" mystr) | +
Results in a compile error if the argument is not a string literal.
+ +#define JSON_EXPORT extern | +
#define printbuf_length | +( | ++ | p | ) | +((p)->bpos) | +
#define printbuf_memappend_fast | +( | ++ | p, | +
+ | + | + | bufptr, | +
+ | + | + | bufsize | +
+ | ) | ++ |
#define printbuf_strappend | +( | ++ | pb, | +
+ | + | + | str | +
+ | ) | +printbuf_memappend((pb), _printbuf_check_literal(str), sizeof(str) - 1) | +
This is an optimization wrapper around printbuf_memappend() that is useful for appending string literals. Since the size of string constants is known at compile time, using this macro can avoid a costly strlen() call. This is especially helpful when a constant string must be appended many times. If you got here because of a compilation error caused by passing something other than a string literal, use printbuf_memappend_fast() in conjunction with strlen().
+See also: printbuf_memappend_fast() printbuf_memappend() sprintbuf()
+ +JSON_EXPORT void printbuf_free | +( | +struct printbuf * | +p | ) | ++ |
JSON_EXPORT int printbuf_memappend | +( | +struct printbuf * | +p, | +
+ | + | const char * | +buf, | +
+ | + | int | +size | +
+ | ) | ++ |
JSON_EXPORT int printbuf_memset | +( | +struct printbuf * | +pb, | +
+ | + | int | +offset, | +
+ | + | int | +charvalue, | +
+ | + | int | +len | +
+ | ) | ++ |
Set len bytes of the buffer to charvalue, starting at offset offset. Similar to calling memset(x, charvalue, len);
+The memory allocated for the buffer is extended as necessary.
+If offset is -1, this starts at the end of the current data in the buffer.
+ +
+
|
+ +read | +
JSON_EXPORT void printbuf_reset | +( | +struct printbuf * | +p | ) | ++ |
JSON_EXPORT int sprintbuf | +( | +struct printbuf * | +p, | +
+ | + | const char * | +msg, | +
+ | + | + | ... | +
+ | ) | ++ |
Formatted print to printbuf.
+This function is the most expensive of the available functions for appending string data to a printbuf and should be used only where convenience is more important than speed. Avoid using this function in high performance code or tight loops; in these scenarios, consider using snprintf() with a static buffer in conjunction with one of the printbuf_*append() functions.
+See also: printbuf_memappend_fast() printbuf_memappend() printbuf_strappend()
+ +
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
++Functions | |
int | json_c_get_random_seed (void) |
Do not use, json-c internal, may be changed or removed at any time.
+int json_c_get_random_seed | +( | +void | +) | ++ |
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
+Do not use, json-c internal, may be changed or removed at any time.
+
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
+Do not use, json-c internal, may be changed or removed at any time.
+
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
++Macros | |
#define | strerror _json_c_strerror |
+Functions | |
JSON_EXPORT char * | _json_c_strerror (int errno_in) |
Do not use, json-c internal, may be changed or removed at any time.
+#define strerror _json_c_strerror | +
JSON_EXPORT char* _json_c_strerror | +( | +int | +errno_in | ) | ++ |
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
++Variables | |
JSON_EXPORT int | _json_c_strerror_enable |
Do not use, json-c internal, may be changed or removed at any time.
+JSON_EXPORT int _json_c_strerror_enable | +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
void ** | array |
size_t | length |
size_t | size |
array_list_free_fn * | free_fn |
void** array_list::array | +
array_list_free_fn* array_list::free_fn | +
size_t array_list::length | +
size_t array_list::size | +
+ json-c
+ 0.14
+
+ |
+
+Data Structures | |
union | data |
+Data Fields | |
enum json_type | o_type |
uint32_t | _ref_count |
json_object_private_delete_fn * | _delete |
json_object_to_json_string_fn * | _to_json_string |
struct printbuf * | _pb |
union json_object::data | o |
json_object_delete_fn * | _user_delete |
void * | _userdata |
json_object_private_delete_fn* json_object::_delete | +
struct printbuf* json_object::_pb | +
uint32_t json_object::_ref_count | +
json_object_to_json_string_fn* json_object::_to_json_string | +
json_object_delete_fn* json_object::_user_delete | +
void* json_object::_userdata | +
union json_object::data json_object::o | +
enum json_type json_object::o_type | +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
char * | key |
struct json_object * | val |
struct lh_entry * | entry |
A structure to use with json_object_object_foreachC() loops. Contains key, val and entry members.
+struct lh_entry* json_object_iter::entry | +
char* json_object_iter::key | +
struct json_object* json_object_iter::val | +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
const void * | opaque_ |
The opaque iterator that references a name/value pair within a JSON Object instance or the "end" iterator value.
+const void* json_object_iterator::opaque_ | +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
char * | str |
struct printbuf * | pb |
int | max_depth |
int | depth |
int | is_double |
int | st_pos |
int | char_offset |
enum json_tokener_error | err |
unsigned int | ucs_char |
char | quote_char |
struct json_tokener_srec * | stack |
int | flags |
Internal state of the json parser. Do not access any fields of this structure directly. Its definition is published due to historical limitations in the json tokener API, and will be changed to be an opaque type in the future.
+int json_tokener::char_offset | +
int json_tokener::depth | +
enum json_tokener_error json_tokener::err | +
int json_tokener::flags | +
int json_tokener::is_double | +
int json_tokener::max_depth | +
struct printbuf* json_tokener::pb | +
char json_tokener::quote_char | +
int json_tokener::st_pos | +
struct json_tokener_srec* json_tokener::stack | +
char* json_tokener::str | +
unsigned int json_tokener::ucs_char | +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
enum json_tokener_state state | saved_state |
struct json_object * | obj |
struct json_object * | current |
char * | obj_field_name |
struct json_object* json_tokener_srec::current | +
struct json_object* json_tokener_srec::obj | +
char* json_tokener_srec::obj_field_name | +
enum json_tokener_state state json_tokener_srec::saved_state | +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
const void * | k |
int | k_is_constant |
const void * | v |
struct lh_entry * | next |
struct lh_entry * | prev |
An entry in the hash table
+const void* lh_entry::k | +
The key. Use lh_entry_k() instead of accessing this directly.
+ +int lh_entry::k_is_constant | +
A flag for users of linkhash to know whether or not they need to free k.
+ +struct lh_entry* lh_entry::next | +
The next entry
+ +struct lh_entry* lh_entry::prev | +
The previous entry.
+ +const void* lh_entry::v | +
The value. Use lh_entry_v() instead of accessing this directly.
+ +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
int | size |
int | count |
struct lh_entry * | head |
struct lh_entry * | tail |
struct lh_entry * | table |
lh_entry_free_fn * | free_fn |
lh_hash_fn * | hash_fn |
lh_equal_fn * | equal_fn |
The hash table structure.
+int lh_table::count | +
Numbers of entries.
+ +lh_equal_fn* lh_table::equal_fn | +
lh_entry_free_fn* lh_table::free_fn | +
A pointer onto the function responsible for freeing an entry.
+ +lh_hash_fn* lh_table::hash_fn | +
struct lh_entry* lh_table::head | +
The first entry.
+ +int lh_table::size | +
Size of our hash.
+ +struct lh_entry* lh_table::table | +
struct lh_entry* lh_table::tail | +
The last entry.
+ +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
char * | buf |
int | bpos |
int | size |
int printbuf::bpos | +
char* printbuf::buf | +
int printbuf::size | +
+ json-c
+ 0.14
+
+ |
+
+Data Fields | |
json_bool | c_boolean |
double | c_double |
struct { | |
union { | |
int64_t c_int64 | |
uint64_t c_uint64 | |
} cint | |
enum json_object_int_type cint_type | |
} | c_int |
struct lh_table * | c_object |
struct array_list * | c_array |
struct { | |
union { | |
char * ptr | |
char data [LEN_DIRECT_STRING_DATA] | |
} str | |
int len | |
} | c_string |
struct array_list* json_object::data::c_array | +
json_bool json_object::data::c_boolean | +
double json_object::data::c_double | +
struct { ... } json_object::data::c_int | +
int64_t json_object::data::c_int64 | +
struct lh_table* json_object::data::c_object | +
struct { ... } json_object::data::c_string | +
uint64_t json_object::data::c_uint64 | +
union { ... } json_object::data::cint | +
enum json_object_int_type json_object::data::cint_type | +
char json_object::data::data[LEN_DIRECT_STRING_DATA] | +
int json_object::data::len | +
char* json_object::data::ptr | +
union { ... } json_object::data::str | +
+ json-c
+ 0.14
+
+ |
+
Do not use, json-c internal, may be changed or removed at any time. +More...
+Do not use, json-c internal, may be changed or removed at any time.
+