summaryrefslogtreecommitdiff
path: root/include/apr_json.h
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2018-08-31 12:25:34 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2018-08-31 12:25:34 +0000
commitedd1cf8b16d9fc187aa05ebe2b78b21bcce8b88e (patch)
treedca3c693f5e09203325ec63e64dff4be4a225cf2 /include/apr_json.h
parent88b8fa42f150c4357efd8431ce5cdabac85f613b (diff)
downloadlibapr-edd1cf8b16d9fc187aa05ebe2b78b21bcce8b88e.tar.gz
apr_json: object keys are strings.
Make this clear in the API by requiring a usual string in apr_json_object_set() and creating the apr_json_string_t from it. It's also more user friendly as otherwise apr_json_string_create() is to be used when setting an entry. Also, axe the 'pool' arg from apr_json_array_add() since it's not needed. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1839755 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/apr_json.h')
-rw-r--r--include/apr_json.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/include/apr_json.h b/include/apr_json.h
index 06ec58ebf..a41180eae 100644
--- a/include/apr_json.h
+++ b/include/apr_json.h
@@ -178,7 +178,7 @@ struct apr_json_object_t {
* Use apr_json_array_create() to allocate.
*/
struct apr_json_array_t {
- /** The key value pairs in the object are in this list */
+ /** The values in the array are in this list */
APR_RING_HEAD(apr_json_array_list_t, apr_json_value_t) list;
/** Array of JSON objects */
apr_array_header_t *array;
@@ -271,8 +271,9 @@ APR_DECLARE(apr_json_value_t *)
/**
* Associate a value with a key in a JSON object.
* @param obj The JSON object.
- * @param key Pointer to the key string, including any whitespace
- * required.
+ * @param key Pointer to the key.
+ * @param klen Length of the key, or APR_JSON_VALUE_STRING if NUL
+ * terminated.
* @param val Value to associate with the key.
* @param pool Pool to use.
* @return APR_SUCCESS on success, APR_EINVAL if the key is
@@ -280,20 +281,19 @@ APR_DECLARE(apr_json_value_t *)
* @remark If the value is NULL the key value pair is deleted.
*/
APR_DECLARE(apr_status_t) apr_json_object_set(apr_json_value_t *obj,
- apr_json_value_t *key, apr_json_value_t *val,
- apr_pool_t *pool) __attribute__((nonnull(1, 4)));
+ const char *key, apr_ssize_t klen, apr_json_value_t *val,
+ apr_pool_t *pool) __attribute__((nonnull(1, 2, 5)));
/**
* Look up the value associated with a key in a JSON object.
* @param obj The JSON object.
* @param key Pointer to the key.
* @param klen Length of the key, or APR_JSON_VALUE_STRING if NUL
- * terminated.
+ * terminated.
* @return Returns NULL if the key is not present.
*/
-APR_DECLARE(apr_json_kv_t *)
- apr_json_object_get(apr_json_value_t *obj, const char *key,
- apr_ssize_t klen)
+APR_DECLARE(apr_json_kv_t *) apr_json_object_get(apr_json_value_t *obj,
+ const char *key, apr_ssize_t klen)
__attribute__((nonnull(1, 2)));
/**
@@ -325,13 +325,12 @@ APR_DECLARE(apr_json_kv_t *) apr_json_object_next(apr_json_value_t *obj,
* Add the value to the end of this array.
* @param arr The JSON array.
* @param val Value to add to the array.
- * @param pool Pool to use.
* @return APR_SUCCESS on success, APR_EINVAL if the array value is not
* an APR_JSON_ARRAY.
*/
APR_DECLARE(apr_status_t) apr_json_array_add(apr_json_value_t *arr,
- apr_json_value_t *val, apr_pool_t *pool)
- __attribute__((nonnull(1, 2, 3)));
+ apr_json_value_t *val)
+ __attribute__((nonnull(1, 2)));
/**
* Look up the value associated with a key in a JSON object.