/* helper for accessing the optimized string data component in json_object
*/
static const char *
-get_string_component(struct json_object *jso)
+get_string_component(const struct json_object *jso)
{
return (jso->o.c_string.len < LEN_DIRECT_STRING_DATA) ?
jso->o.c_string.str.data : jso->o.c_string.str.ptr;
/* type checking functions */
-int json_object_is_type(struct json_object *jso, enum json_type type)
+int json_object_is_type(const struct json_object *jso, enum json_type type)
{
if (!jso)
return (type == json_type_null);
return (jso->o_type == type);
}
-enum json_type json_object_get_type(struct json_object *jso)
+enum json_type json_object_get_type(const struct json_object *jso)
{
if (!jso)
return json_type_null;
return jso;
}
-struct lh_table* json_object_get_object(struct json_object *jso)
+struct lh_table* json_object_get_object(const struct json_object *jso)
{
if (!jso)
return NULL;
}
-int json_object_object_length(struct json_object *jso)
+int json_object_object_length(const struct json_object *jso)
{
return lh_table_length(jso->o.c_object);
}
-struct json_object* json_object_object_get(struct json_object* jso, const char *key)
+struct json_object* json_object_object_get(const struct json_object* jso, const char *key)
{
struct json_object *result = NULL;
json_object_object_get_ex(jso, key, &result);
return result;
}
-json_bool json_object_object_get_ex(struct json_object* jso, const char *key, struct json_object **value)
+json_bool json_object_object_get_ex(const struct json_object* jso, const char *key, struct json_object **value)
{
if (value != NULL)
*value = NULL;
return jso;
}
-json_bool json_object_get_boolean(struct json_object *jso)
+json_bool json_object_get_boolean(const struct json_object *jso)
{
if (!jso)
return FALSE;
return jso;
}
-int32_t json_object_get_int(struct json_object *jso)
+int32_t json_object_get_int(const struct json_object *jso)
{
int64_t cint64;
enum json_type o_type;
return jso;
}
-int64_t json_object_get_int64(struct json_object *jso)
+int64_t json_object_get_int64(const struct json_object *jso)
{
int64_t cint;
free(userdata);
}
-double json_object_get_double(struct json_object *jso)
+double json_object_get_double(const struct json_object *jso)
{
double cdouble;
char *errPtr = NULL;
}
}
-int json_object_get_string_len(struct json_object *jso)
+int json_object_get_string_len(const struct json_object *jso)
{
if (!jso)
return 0;
return jso;
}
-struct array_list* json_object_get_array(struct json_object *jso)
+struct array_list* json_object_get_array(const struct json_object *jso)
{
if (!jso)
return NULL;
return *result;
}
-int json_object_array_length(struct json_object *jso)
+int json_object_array_length(const struct json_object *jso)
{
return array_list_length(jso->o.c_array);
}
return array_list_put_idx(jso->o.c_array, idx, val);
}
-struct json_object* json_object_array_get_idx(struct json_object *jso,
+struct json_object* json_object_array_get_idx(const struct json_object *jso,
int idx)
{
return (struct json_object*)array_list_get_idx(jso->o.c_array, idx);
json_type_array,
json_type_string
*/
-extern int json_object_is_type(struct json_object *obj, enum json_type type);
+extern int json_object_is_type(const struct json_object *obj, enum json_type type);
/**
* Get the type of the json_object. See also json_type_to_name() to turn this
json_type_array,
json_type_string
*/
-extern enum json_type json_object_get_type(struct json_object *obj);
+extern enum json_type json_object_get_type(const struct json_object *obj);
/** Stringify object to json format.
* @param obj the json_object instance
* @returns a linkhash
*/
-extern struct lh_table* json_object_get_object(struct json_object *obj);
+extern struct lh_table* json_object_get_object(const struct json_object *obj);
/** Get the size of an object in terms of the number of fields it has.
* @param obj the json_object whose length to return
*/
-extern int json_object_object_length(struct json_object* obj);
+extern int json_object_object_length(const struct json_object* obj);
/** Add an object field to a json_object of type json_type_object
*
* @returns the json_object associated with the given field name
* @deprecated Please use json_object_object_get_ex
*/
-THIS_FUNCTION_IS_DEPRECATED(extern struct json_object* json_object_object_get(struct json_object* obj,
+THIS_FUNCTION_IS_DEPRECATED(extern struct json_object* json_object_object_get(const struct json_object* obj,
const char *key));
/** Get the json_object associated with a given object field.
* It is safe to pass a NULL value.
* @returns whether or not the key exists
*/
-extern json_bool json_object_object_get_ex(struct json_object* obj,
- const char *key,
- struct json_object **value);
+extern json_bool json_object_object_get_ex(const struct json_object* obj,
+ const char *key,
+ struct json_object **value);
/** Delete the given json_object field
*
* @param obj the json_object instance
* @returns an arraylist
*/
-extern struct array_list* json_object_get_array(struct json_object *obj);
+extern struct array_list* 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
*/
-extern int json_object_array_length(struct json_object *obj);
+extern int json_object_array_length(const struct json_object *obj);
/** Sorts the elements of jso of type json_type_array
*
* @param idx the index to get the element at
* @returns the json_object at the specified index (or NULL)
*/
-extern struct json_object* json_object_array_get_idx(struct json_object *obj,
+extern struct json_object* json_object_array_get_idx(const struct json_object *obj,
int idx);
/* json_bool type methods */
* @param obj the json_object instance
* @returns a json_bool
*/
-extern json_bool json_object_get_boolean(struct json_object *obj);
+extern json_bool json_object_get_boolean(const struct json_object *obj);
/* int type methods */
* @param obj the json_object instance
* @returns an int
*/
-extern int32_t json_object_get_int(struct json_object *obj);
+extern int32_t json_object_get_int(const struct json_object *obj);
/** Get the int value of a json_object
*
* @param obj the json_object instance
* @returns an int64
*/
-extern int64_t json_object_get_int64(struct json_object *obj);
+extern int64_t json_object_get_int64(const struct json_object *obj);
/* double type methods */
* @param obj the json_object instance
* @returns a double floating point number
*/
-extern double json_object_get_double(struct json_object *obj);
+extern double json_object_get_double(const struct json_object *obj);
/* string type methods */
* @param obj the json_object instance
* @returns int
*/
-extern int json_object_get_string_len(struct json_object *obj);
+extern int json_object_get_string_len(const struct json_object *obj);
#ifdef __cplusplus
}