From 88dd316f757a0ef7df3af1965acd0e87a788d541 Mon Sep 17 00:00:00 2001
From: Tomer Cabouly 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-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.
Doxygen generated documentation exists here
- and Win32 specific notes can be found here. Doxygen generated documentation exists here. JSON-C - A JSON implementation in C
Overview
- Building
Documentation
- GIT Reposository
git clone https://github.com/json-c/json-c.gitMailing List
+ Mailing List
json-c <at> googlegroups <dot> com
0 is returned.
* On error, a negative value is returned.
*/
-JSON_EXPORT int json_object_object_add(struct json_object* obj, const char *key,
- struct json_object *val);
+JSON_EXPORT int doca_third_party_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
*
@@ -435,20 +426,18 @@ JSON_EXPORT int json_object_object_add(struct json_object* obj, const char *key,
* @param obj the json_object instance
* @param key the object field name (a private copy will be duplicated)
* @param val a json_object or NULL member to associate with the given field
- * @param opts process-modifying options. To specify multiple options, use
- * arithmetic or (OPT1|OPT2)
+ * @param opts process-modifying options. To specify multiple options, use
+ * (OPT1|OPT2)
*/
-JSON_EXPORT int json_object_object_add_ex(struct json_object* obj,
- const char *const key,
- struct json_object *const val,
- const unsigned opts);
+JSON_EXPORT int doca_third_party_json_object_object_add_ex(struct json_object *obj, const char *const key,
+ struct json_object *const val, const unsigned opts);
/** 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 distinguis between these cases, use json_object_object_get_ex().
+ * 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
@@ -464,8 +453,8 @@ JSON_EXPORT int json_object_object_add_ex(struct json_object* obj,
* @param key the object field name
* @returns the json_object associated with the given field name
*/
-JSON_EXPORT struct json_object* json_object_object_get(const struct json_object* obj,
- const char *key);
+JSON_EXPORT struct json_object *doca_third_party_json_object_object_get(const struct json_object *obj,
+ const char *key);
/** Get the json_object associated with a given object field.
*
@@ -485,9 +474,8 @@ JSON_EXPORT struct json_object* json_object_object_get(const struct json_object*
* It is safe to pass a NULL value.
* @returns whether or not the key exists
*/
-JSON_EXPORT json_bool json_object_object_get_ex(const struct json_object* obj,
- const char *key,
- struct json_object **value);
+JSON_EXPORT json_bool doca_third_party_json_object_object_get_ex(const struct json_object *obj, const char *key,
+ struct json_object **value);
/** Delete the given json_object field
*
@@ -498,7 +486,7 @@ JSON_EXPORT json_bool json_object_object_get_ex(const struct json_object* obj,
* @param obj the json_object instance
* @param key the object field name
*/
-JSON_EXPORT void json_object_object_del(struct json_object* obj, const char *key);
+JSON_EXPORT void doca_third_party_json_object_object_del(struct json_object *obj, const char *key);
/**
* Iterate through all keys and values of an object.
@@ -513,63 +501,82 @@ JSON_EXPORT void json_object_object_del(struct json_object* obj, const char *key
* @param val the local name for the json_object* object variable defined in
* the body
*/
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && __STDC_VERSION__ >= 199901L
-
-# define json_object_object_foreach(obj,key,val) \
- char *key = NULL; \
- struct json_object *val __attribute__((__unused__)) = NULL; \
- for(struct lh_entry *entry ## key = json_object_get_object(obj)->head, *entry_next ## key = NULL; \
- ({ if(entry ## key) { \
- key = (char*)lh_entry_k(entry ## key); \
- val = (struct json_object*)lh_entry_v(entry ## key); \
- entry_next ## key = entry ## key->next; \
- } ; entry ## key; }); \
- entry ## key = entry_next ## key )
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
+
+#define doca_third_party_json_object_object_foreach(obj, key, val) \
+ char *key = NULL; \
+ struct json_object *val __attribute__((__unused__)) = NULL; \
+ for (struct lh_entry *entry##key = lh_table_head(doca_third_party_json_object_get_object(obj)), \
+ *entry_next##key = NULL; \
+ ({ \
+ if (entry##key) \
+ { \
+ key = (char *)lh_entry_k(entry##key); \
+ val = (struct json_object *)lh_entry_v(entry##key); \
+ entry_next##key = lh_entry_next(entry##key); \
+ }; \
+ entry##key; \
+ }); \
+ entry##key = entry_next##key)
#else /* ANSI C or MSC */
-# define json_object_object_foreach(obj,key,val) \
- char *key = NULL;\
- struct json_object *val = NULL; \
- struct lh_entry *entry ## key; \
- struct lh_entry *entry_next ## key = NULL; \
- for(entry ## key = json_object_get_object(obj)->head; \
- (entry ## key ? ( \
- key = (char*)lh_entry_k(entry ## key), \
- val = (struct json_object*)lh_entry_v(entry ## key), \
- entry_next ## key = entry ## key->next, \
- entry ## key) : 0); \
- entry ## key = entry_next ## key)
-
-#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) && __STDC_VERSION__ >= 199901L */
+#define doca_third_party_json_object_object_foreach(obj, key, val) \
+ char *key = NULL; \
+ struct json_object *val = NULL; \
+ struct lh_entry *entry##key; \
+ struct lh_entry *entry_next##key = NULL; \
+ for (entry##key = lh_table_head(doca_third_party_json_object_get_object(obj)); \
+ (entry##key ? (key = (char *)lh_entry_k(entry##key), \
+ val = (struct json_object *)lh_entry_v(entry##key), \
+ entry_next##key = lh_entry_next(entry##key), entry##key) \
+ : 0); \
+ entry##key = entry_next##key)
+
+#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) */
/** Iterate through all keys and values of an object (ANSI C Safe)
* @param obj the json_object instance
* @param iter the object iterator, use type json_object_iter
*/
-#define json_object_object_foreachC(obj,iter) \
- for(iter.entry = json_object_get_object(obj)->head; \
- (iter.entry ? (iter.key = (char*)lh_entry_k(iter.entry), iter.val = (struct json_object*)lh_entry_v(iter.entry), iter.entry) : 0); \
- iter.entry = iter.entry->next)
+#define doca_third_party_json_object_object_foreachC(obj, iter) \
+ for (iter.entry = lh_table_head(doca_third_party_json_object_get_object(obj)); \
+ (iter.entry ? (iter.key = (char *)lh_entry_k(iter.entry), \
+ iter.val = (struct json_object *)lh_entry_v(iter.entry), iter.entry) \
+ : 0); \
+ iter.entry = lh_entry_next(iter.entry))
/* Array type methods */
/** Create a new empty json_object of type json_type_array
+ * with 32 slots allocated.
+ * If you know the array size you'll need ahead of time, use
+ * json_object_new_array_ext() instead.
+ * @see json_object_new_array_ext()
+ * @see json_object_array_shrink()
+ * @returns a json_object of type json_type_array
+ */
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_array(void);
+
+/** Create a new empty json_object of type json_type_array
+ * with the desired number of slots allocated.
+ * @see json_object_array_shrink()
+ * @param initial_size the number of slots to allocate
* @returns a json_object of type json_type_array
*/
-JSON_EXPORT struct json_object* json_object_new_array(void);
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_array_ext(int initial_size);
/** Get the arraylist of a json_object of type json_type_array
* @param obj the json_object instance
* @returns an arraylist
*/
-JSON_EXPORT struct array_list* json_object_get_array(const struct json_object *obj);
+JSON_EXPORT struct array_list *doca_third_party_json_object_get_array(const struct json_object *obj);
/** Get the length of a json_object of type json_type_array
* @param obj the json_object instance
* @returns an int
*/
-JSON_EXPORT size_t json_object_array_length(const struct json_object *obj);
+JSON_EXPORT size_t doca_third_party_json_object_array_length(const struct json_object *obj);
/** Sorts the elements of jso of type json_type_array
*
@@ -579,7 +586,8 @@ JSON_EXPORT size_t json_object_array_length(const struct json_object *obj);
* @param jso the json_object instance
* @param sort_fn a sorting function
*/
-JSON_EXPORT void json_object_array_sort(struct json_object *jso, int(*sort_fn)(const void *, const void *));
+JSON_EXPORT void doca_third_party_json_object_array_sort(struct json_object *jso,
+ int (*sort_fn)(const void *, const void *));
/** Binary search a sorted array for a specified key object.
*
@@ -595,10 +603,9 @@ JSON_EXPORT void json_object_array_sort(struct json_object *jso, int(*sort_fn)(c
*
* @return the wanted json_object instance
*/
-JSON_EXPORT struct json_object* json_object_array_bsearch(
- const struct json_object *key,
- const struct json_object *jso,
- int (*sort_fn)(const void *, const void *));
+JSON_EXPORT struct json_object *
+doca_third_party_json_object_array_bsearch(const struct json_object *key, const struct json_object *jso,
+ int (*sort_fn)(const void *, const void *));
/** Add an element to the end of a json_object of type json_type_array
*
@@ -609,8 +616,7 @@ JSON_EXPORT struct json_object* json_object_array_bsearch(
* @param obj the json_object instance
* @param val the json_object to be added
*/
-JSON_EXPORT int json_object_array_add(struct json_object *obj,
- struct json_object *val);
+JSON_EXPORT int doca_third_party_json_object_array_add(struct json_object *obj, struct json_object *val);
/** Insert or replace an element at a specified index in an array (a json_object of type json_type_array)
*
@@ -627,21 +633,48 @@ JSON_EXPORT int json_object_array_add(struct json_object *obj,
* @param idx the index to insert the element at
* @param val the json_object to be added
*/
-JSON_EXPORT int json_object_array_put_idx(struct json_object *obj, size_t idx,
- struct json_object *val);
+JSON_EXPORT int doca_third_party_json_object_array_put_idx(struct json_object *obj, size_t idx,
+ struct json_object *val);
+
+/** Insert 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 array size will be automatically be expanded to the size of the
+ * index if the index is larger than the current size.
+ * If the index is within the existing array limits, then the element will be
+ * inserted and all elements will be shifted. This is the only difference between
+ * this function and json_object_array_put_idx().
+ *
+ * @param obj the json_object instance
+ * @param idx the index to insert the element at
+ * @param val the json_object to be added
+ */
+JSON_EXPORT int doca_third_party_json_object_array_insert_idx(struct json_object *obj, size_t idx,
+ struct json_object *val);
-/** Get the element at specificed index of the array (a json_object of type json_type_array)
+/** Get the element at specified index of array `obj` (which must be a json_object of type json_type_array)
+ *
+ * *No* reference counts will be changed, and ownership of the returned
+ * object remains with `obj`. See json_object_object_get() for additional
+ * implications of this behavior.
+ *
+ * Calling this with anything other than a json_type_array will trigger
+ * an assert.
+ *
* @param obj the json_object instance
* @param idx the index to get the element at
* @returns the json_object at the specified index (or NULL)
*/
-JSON_EXPORT struct json_object* json_object_array_get_idx(const struct json_object *obj,
- size_t idx);
+JSON_EXPORT struct json_object *doca_third_party_json_object_array_get_idx(const struct json_object *obj,
+ size_t idx);
/** 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
+ * 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.
*
* @param obj the json_object instance
@@ -649,42 +682,50 @@ JSON_EXPORT struct json_object* json_object_array_get_idx(const struct json_obje
* @param count the number of elements to delete
* @returns 0 if the elements were successfully deleted
*/
-JSON_EXPORT int json_object_array_del_idx(struct json_object *obj, size_t idx, size_t count);
+JSON_EXPORT int doca_third_party_json_object_array_del_idx(struct json_object *obj, size_t idx, size_t count);
+
+/**
+ * Shrink the internal memory allocation of the array to just
+ * enough to fit the number of elements in it, plus empty_slots.
+ *
+ * @param jso the json_object instance, must be json_type_array
+ * @param empty_slots the number of empty slots to leave allocated
+ */
+JSON_EXPORT int doca_third_party_json_object_array_shrink(struct json_object *jso, int empty_slots);
/* json_bool type methods */
/** Create a new empty json_object of type json_type_boolean
- * @param b a json_bool TRUE or FALSE (1 or 0)
+ * @param b a json_bool 1 or 0
* @returns a json_object of type json_type_boolean
*/
-JSON_EXPORT struct json_object* json_object_new_boolean(json_bool b);
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_boolean(json_bool b);
/** 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 FALSE if there value is zero
- * or TRUE otherwise. If the passed object is a string it will return
- * TRUE if it has a non zero length. If any other object type is passed
- * TRUE will be returned if the object is not NULL.
+ * 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 0 will be returned, even non-empty
+ * json_type_array and json_type_object objects.
*
* @param obj the json_object instance
* @returns a json_bool
*/
-JSON_EXPORT json_bool json_object_get_boolean(const struct json_object *obj);
-
+JSON_EXPORT json_bool doca_third_party_json_object_get_boolean(const struct json_object *obj);
/** 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
+ *
+ * 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 obect value is chaned to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
-JSON_EXPORT int json_object_set_boolean(struct json_object *obj,json_bool new_value);
-
+JSON_EXPORT int doca_third_party_json_object_set_boolean(struct json_object *obj, json_bool new_value);
/* int type methods */
@@ -694,15 +735,19 @@ JSON_EXPORT int json_object_set_boolean(struct json_object *obj,json_bool new_va
* @param i the integer
* @returns a json_object of type json_type_int
*/
-JSON_EXPORT struct json_object* json_object_new_int(int32_t i);
-
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_int(int32_t i);
/** Create a new empty json_object of type json_type_int
* @param i the integer
* @returns a json_object of type json_type_int
*/
-JSON_EXPORT struct json_object* json_object_new_int64(int64_t i);
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_int64(int64_t i);
+/** Create a new empty json_object of type json_type_uint
+ * @param i the integer
+ * @returns a json_object of type json_type_uint
+ */
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_uint64(uint64_t i);
/** Get the int value of a json_object
*
@@ -718,19 +763,19 @@ JSON_EXPORT struct json_object* json_object_new_int64(int64_t i);
* @param obj the json_object instance
* @returns an int
*/
-JSON_EXPORT int32_t json_object_get_int(const struct json_object *obj);
+JSON_EXPORT int32_t doca_third_party_json_object_get_int(const struct json_object *obj);
/** Set the int value of a json_object
- *
- * The type of obj is checked to be a json_type_int and 0 is returned
+ *
+ * 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 obect value is changed to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
-JSON_EXPORT int json_object_set_int(struct json_object *obj,int new_value);
+JSON_EXPORT int doca_third_party_json_object_set_int(struct json_object *obj, int new_value);
/** Increment a json_type_int object by the given amount, which may be negative.
*
@@ -744,10 +789,9 @@ JSON_EXPORT int json_object_set_int(struct json_object *obj,int new_value);
*
* @param obj the json_object instance
* @param val the value to add
- * @returns 1 if the increment succeded, 0 otherwise
+ * @returns 1 if the increment succeeded, 0 otherwise
*/
-JSON_EXPORT int json_object_int_inc(struct json_object *obj, int64_t val);
-
+JSON_EXPORT int doca_third_party_json_object_int_inc(struct json_object *obj, int64_t val);
/** Get the int value of a json_object
*
@@ -762,20 +806,46 @@ JSON_EXPORT int json_object_int_inc(struct json_object *obj, int64_t val);
* @param obj the json_object instance
* @returns an int64
*/
-JSON_EXPORT int64_t json_object_get_int64(const struct json_object *obj);
+JSON_EXPORT int64_t doca_third_party_json_object_get_int64(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).
+ *
+ * @param obj the json_object instance
+ * @returns an uint64
+ */
+JSON_EXPORT uint64_t doca_third_party_json_object_get_uint64(const struct json_object *obj);
/** 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
+ *
+ * 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 obect value is chaned to new_value
+ * the object value is changed to new_value
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int doca_third_party_json_object_set_int64(struct json_object *obj, int64_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
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
-JSON_EXPORT int json_object_set_int64(struct json_object *obj,int64_t new_value);
+JSON_EXPORT int doca_third_party_json_object_set_uint64(struct json_object *obj, uint64_t new_value);
/* double type methods */
@@ -786,7 +856,7 @@ JSON_EXPORT int json_object_set_int64(struct json_object *obj,int64_t new_value)
* @param d the double
* @returns a json_object of type json_type_double
*/
-JSON_EXPORT struct json_object* json_object_new_double(double d);
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_double(double d);
/**
* Create a new json_object of type json_type_double, using
@@ -804,7 +874,8 @@ JSON_EXPORT struct json_object* json_object_new_double(double d);
* The userdata field is used to store the string representation, so it
* can't be used for other data if this function is used.
*
- * An equivalent sequence of calls is:
+ * A roughly equivalent sequence of calls, with the difference being that
+ * the serialization function won't be reset by json_object_set_double(), is:
* @code
* jso = json_object_new_double(d);
* json_object_set_serializer(jso, json_object_userdata_to_json_string,
@@ -814,7 +885,7 @@ JSON_EXPORT struct json_object* json_object_new_double(double d);
* @param d the numeric value of the double.
* @param ds the string representation of the double. This will be copied.
*/
-JSON_EXPORT struct json_object* json_object_new_double_s(double d, const char *ds);
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_double_s(double d, const char *ds);
/**
* Set a global or thread-local json-c option, depending on whether
@@ -828,9 +899,8 @@ JSON_EXPORT struct json_object* json_object_new_double_s(double d, const char *d
*
* @return -1 on errors, 0 on success.
*/
-int json_c_set_serialization_double_format(const char *double_format, int global_or_thread);
-
-
+JSON_EXPORT int doca_third_party_json_c_set_serialization_double_format(const char *double_format,
+ int global_or_thread);
/** Serialize a json_object of type json_type_double to a string.
*
@@ -851,10 +921,8 @@ int json_c_set_serialization_double_format(const char *double_format, int global
* @param level Ignored.
* @param flags Ignored.
*/
-JSON_EXPORT int json_object_double_to_json_string(struct json_object* jso,
- struct printbuf *pb,
- int level,
- int flags);
+JSON_EXPORT int doca_third_party_json_object_double_to_json_string(struct json_object *jso, struct printbuf *pb,
+ int level, int flags);
/** Get the double floating point value of a json_object
*
@@ -879,22 +947,22 @@ JSON_EXPORT int json_object_double_to_json_string(struct json_object* jso,
* @param obj the json_object instance
* @returns a double floating point number
*/
-JSON_EXPORT double json_object_get_double(const struct json_object *obj);
-
+JSON_EXPORT double doca_third_party_json_object_get_double(const struct json_object *obj);
/** Set the double value of a json_object
- *
- * The type of obj is checked to be a json_type_double and 0 is returned
+ *
+ * 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 obect value is chaned to new_value
+ * 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.
*
* @param obj the json_object instance
* @param new_value the value to be set
* @returns 1 if value is set correctly, 0 otherwise
*/
-JSON_EXPORT int json_object_set_double(struct json_object *obj,double new_value);
-
-
+JSON_EXPORT int doca_third_party_json_object_set_double(struct json_object *obj, double new_value);
/* string type methods */
@@ -904,10 +972,21 @@ JSON_EXPORT int json_object_set_double(struct json_object *obj,double new_value)
*
* @param s the string
* @returns a json_object of type json_type_string
+ * @see json_object_new_string_len()
*/
-JSON_EXPORT struct json_object* json_object_new_string(const char *s);
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_string(const char *s);
-JSON_EXPORT struct json_object* json_object_new_string_len(const char *s, int len);
+/** 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
+ *
+ * @param s the string
+ * @param len max length of the new string
+ * @returns a json_object of type json_type_string
+ * @see json_object_new_string()
+ */
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_string_len(const char *s, const int len);
/** Get the string value of a json_object
*
@@ -925,7 +1004,7 @@ JSON_EXPORT struct json_object* json_object_new_string_len(const char *s, int le
* @param obj the json_object instance
* @returns a string or NULL
*/
-JSON_EXPORT const char* json_object_get_string(struct json_object *obj);
+JSON_EXPORT const char *doca_third_party_json_object_get_string(struct json_object *obj);
/** Get the string length of a json_object
*
@@ -935,27 +1014,32 @@ JSON_EXPORT const char* json_object_get_string(struct json_object *obj);
* @param obj the json_object instance
* @returns int
*/
-JSON_EXPORT int json_object_get_string_len(const struct json_object *obj);
-
+JSON_EXPORT int doca_third_party_json_object_get_string_len(const struct json_object *obj);
/** 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))
* @returns 1 if value is set correctly, 0 otherwise
*/
-JSON_EXPORT int json_object_set_string(json_object* obj, const char* new_value);
+JSON_EXPORT int doca_third_party_json_object_set_string(json_object *obj, const char *new_value);
/** 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
+ *
+ * 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 obect value is chaned to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
- * @param new_value the value to be set; Since string legth is given in len this need not be zero terminated
+ * @param new_value the value to be set; Since string length is given in len this need not be zero terminated
* @param len the length of new_value
* @returns 1 if value is set correctly, 0 otherwise
*/
-JSON_EXPORT int json_object_set_string_len(json_object* obj, const char* new_value, int len);
+JSON_EXPORT int doca_third_party_json_object_set_string_len(json_object *obj, const char *new_value, int len);
+
+/** 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.
+ */
+JSON_EXPORT struct json_object *doca_third_party_json_object_new_null(void);
/** Check if two json_object's are equal
*
@@ -974,8 +1058,7 @@ JSON_EXPORT int json_object_set_string_len(json_object* obj, const char* new_val
* @param obj2 the second json_object instance
* @returns whether both objects are equal or not
*/
-JSON_EXPORT int json_object_equal(struct json_object *obj1,
- struct json_object *obj2);
+JSON_EXPORT int doca_third_party_json_object_equal(struct json_object *obj1, struct json_object *obj2);
/**
* Perform a shallow copy of src into *dst as part of an overall json_object_deep_copy().
@@ -985,17 +1068,18 @@ JSON_EXPORT int json_object_equal(struct json_object *obj1,
* 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
+ * 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.
*
* @return On success 1 or 2, -1 on errors
*/
-typedef int (json_c_shallow_copy_fn)(json_object *src, json_object *parent, const char *key, size_t index, json_object **dst);
+typedef int(json_c_shallow_copy_fn)(json_object *src, json_object *parent, const char *key,
+ size_t index, json_object **dst);
/**
* The default shallow copy implementation for use with json_object_deep_copy().
- * This simply calls the appropriate json_object_new_