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...
|
struct array_list * | array_list_new (array_list_free_fn *free_fn) |
|
struct array_list * | array_list_new2 (array_list_free_fn *free_fn, int initial_size) |
|
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) |
|
int | array_list_shrink (struct array_list *arr, size_t empty_slots) |
|
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.
◆ ARRAY_LIST_DEFAULT_SIZE
#define ARRAY_LIST_DEFAULT_SIZE 32 |
◆ array_list
◆ array_list_free_fn
typedef void() array_list_free_fn(void *data) |
◆ array_list_add()
int array_list_add |
( |
struct array_list * |
al, |
|
|
void * |
data |
|
) |
| |
◆ array_list_bsearch()
void* array_list_bsearch |
( |
const void ** |
key, |
|
|
struct array_list * |
arr, |
|
|
int(*)(const void *, const void *) |
compar |
|
) |
| |
◆ array_list_del_idx()
int array_list_del_idx |
( |
struct array_list * |
arr, |
|
|
size_t |
idx, |
|
|
size_t |
count |
|
) |
| |
◆ array_list_free()
◆ array_list_get_idx()
void* array_list_get_idx |
( |
struct array_list * |
al, |
|
|
size_t |
i |
|
) |
| |
◆ array_list_length()
size_t array_list_length |
( |
struct array_list * |
al | ) |
|
◆ array_list_new()
◆ array_list_new2()
Allocate an array_list of the desired size.
If possible, the size should be chosen to closely match the actual number of elements expected to be used. If the exact size is unknown, there are tradeoffs to be made:
- too small - the array_list code will need to call realloc() more often (which might incur an additional memory copy).
- too large - will waste memory, but that can be mitigated by calling array_list_shrink() once the final size is known.
- See also
- array_list_shrink
◆ array_list_put_idx()
int array_list_put_idx |
( |
struct array_list * |
al, |
|
|
size_t |
i, |
|
|
void * |
data |
|
) |
| |
◆ array_list_shrink()
int array_list_shrink |
( |
struct array_list * |
arr, |
|
|
size_t |
empty_slots |
|
) |
| |
Shrink the array list to just enough to fit the number of elements in it, plus empty_slots.
◆ array_list_sort()
void array_list_sort |
( |
struct array_list * |
arr, |
|
|
int(*)(const void *, const void *) |
compar |
|
) |
| |
array_list_free_fn * free_fn
Definition: arraylist.h:36
void array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *))
JSON_EXPORT void json_object_set_userdata(json_object *jso, void *userdata, json_object_delete_fn *user_delete)
@ json_type_object
Definition: json_types.h:69
@ json_tokener_success
Definition: json_tokener.h:28
#define JSON_C_CONST_FUNCTION(func)
Definition: json_object.h:23
JSON_EXPORT int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value)
JSON_EXPORT struct json_object * json_object_new_object(void)
JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok)
An API for iterating over json_type_object objects, styled to be familiar to C++ programmers....
unsigned long() lh_hash_fn(const void *k)
Definition: linkhash.h:76
JSON_EXPORT int printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len)
@ json_tokener_state_comment_start
Definition: json_tokener.h:55
JSON_EXPORT struct printbuf * printbuf_new(void)
JSON_EXPORT struct json_object * json_tokener_parse(const char *str)
JSON_EXPORT int json_object_deep_copy(struct json_object *src, struct json_object **dst, json_c_shallow_copy_fn *shallow_copy)
JSON_EXPORT struct array_list * json_object_get_array(const struct json_object *obj)
JSON_EXPORT struct json_tokener * json_tokener_new_ex(int depth)
JSON_EXPORT json_bool json_object_object_get_ex(const struct json_object *obj, const char *key, struct json_object **value)
json_bool lh_table_lookup_ex(struct lh_table *t, const void *k, void **v)
JSON_EXPORT int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt,...)
int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e)
@ json_tokener_state_eatws
Definition: json_tokener.h:51
Definition: linkhash.h:113
JSON_EXPORT int json_parse_uint64(const char *buf, uint64_t *retval)
@ json_tokener_state_object_field
Definition: json_tokener.h:70
void() json_object_delete_fn(struct json_object *jso, void *userdata)
Definition: json_types.h:52
Do not use, json-c internal, may be changed or removed at any time.
struct lh_entry * tail
Definition: linkhash.h:132
JSON_EXPORT struct json_object * json_object_new_null(void)
@ json_tokener_state_string_escape
Definition: json_tokener.h:60
@ json_type_int
Definition: json_types.h:68
JSON_EXPORT void * json_object_get_userdata(json_object *jso)
int size
Definition: linkhash.h:118
int char_offset
Definition: json_tokener.h:111
JSON_EXPORT json_object_delete_fn json_object_free_userdata
Definition: json_object.h:312
int() json_c_visit_userfunc(json_object *jso, int flags, json_object *parent_jso, const char *jso_key, size_t *jso_index, void *userarg)
Definition: json_visit.h:15
const JSON_EXPORT char * json_object_get_string(struct json_object *obj)
int count
Definition: linkhash.h:122
@ json_tokener_continue
Definition: json_tokener.h:29
JSON_EXPORT void json_tokener_reset(struct json_tokener *tok)
JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.
int() json_c_shallow_copy_fn(json_object *src, json_object *parent, const char *key, size_t index, json_object **dst)
Definition: json_object.h:1026
JSON_EXPORT struct json_object * json_object_new_array_ext(int initial_size)
JSON_EXPORT struct lh_table * json_object_get_object(const struct json_object *obj)
JSON_EXPORT void printbuf_reset(struct printbuf *p)
Definition: printbuf.h:38
void * array_list_get_idx(struct array_list *al, size_t i)
struct json_object json_object
The core type for all type of JSON objects handled by json-c.
Definition: json_types.h:47
@ json_tokener_error_parse_object_key_sep
Definition: json_tokener.h:38
@ json_tokener_state_array_add
Definition: json_tokener.h:67
struct lh_entry * table
Definition: linkhash.h:134
JSON_EXPORT int json_object_array_del_idx(struct json_object *obj, size_t idx, size_t count)
@ json_tokener_state_array_after_sep
Definition: json_tokener.h:75
@ json_tokener_state_comment
Definition: json_tokener.h:56
Definition: json_types.h:34
Definition: json_tokener.h:100
@ json_tokener_error_parse_array
Definition: json_tokener.h:36
JSON_EXPORT enum json_type json_object_get_type(const struct json_object *obj)
struct printbuf * pb
Definition: json_tokener.h:106
JSON_EXPORT int json_object_double_to_json_string(struct json_object *jso, struct printbuf *pb, int level, int flags)
JSON_EXPORT struct json_object * json_object_new_string(const char *s)
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)
int depth
Definition: json_tokener.h:107
struct array_list * array_list_new2(array_list_free_fn *free_fn, int initial_size)
Internal string buffer handing. Unless you're writing a json_object_to_json_string_fn implementation ...
JSON_EXPORT void json_object_iter_next(struct json_object_iterator *iter)
JSON_EXPORT int json_object_int_inc(struct json_object *obj, int64_t val)
@ json_tokener_state_escape_unicode_need_escape
Definition: json_tokener.h:62
int() lh_equal_fn(const void *k1, const void *k2)
Definition: linkhash.h:80
@ json_tokener_state_object_value
Definition: json_tokener.h:72
JSON_EXPORT int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt,...)
struct json_object * obj
Definition: json_tokener.h:86
JSON_EXPORT int json_object_array_put_idx(struct json_object *obj, size_t idx, struct json_object *val)
JSON_EXPORT struct json_object * json_object_from_fd_ex(int fd, int depth)
JSON_EXPORT void printbuf_free(struct printbuf *p)
Methods for retrieving the json-c version.
JSON_EXPORT int json_object_get_string_len(const struct json_object *obj)
JSON_EXPORT int json_object_array_add(struct json_object *obj, struct json_object *val)
void() array_list_free_fn(void *data)
Definition: arraylist.h:29
JSON_EXPORT uint64_t json_object_get_uint64(const struct json_object *obj)
JSON_EXPORT struct json_object * json_object_new_int64(int64_t i)
JSON_EXPORT int json_object_set_int64(struct json_object *obj, int64_t new_value)
int is_double
Definition: json_tokener.h:107
struct lh_table * lh_table_new(int size, lh_entry_free_fn *free_fn, lh_hash_fn *hash_fn, lh_equal_fn *equal_fn)
@ json_tokener_state_comment_end
Definition: json_tokener.h:58
@ json_tokener_state_object_sep
Definition: json_tokener.h:74
JSON_EXPORT json_bool json_object_get_boolean(const struct json_object *obj)
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_type_double
Definition: json_types.h:67
int flags
Definition: json_tokener.h:119
const JSON_EXPORT char * json_c_version(void)
JSON_EXPORT int json_object_put(struct json_object *obj)
@ json_tokener_error_parse_unexpected
Definition: json_tokener.h:32
struct lh_entry * entry
Definition: json_types.h:38
@ json_tokener_error_parse_number
Definition: json_tokener.h:35
JSON_EXPORT json_bool json_object_iter_equal(const struct json_object_iterator *iter1, const struct json_object_iterator *iter2)
@ json_tokener_state_object_field_end
Definition: json_tokener.h:71
JSON_EXPORT struct json_object * json_object_object_get(const struct json_object *obj, const char *key)
JSON_EXPORT int json_c_version_num(void)
JSON_EXPORT struct json_object_iterator json_object_iter_init_default(void)
JSON_EXPORT int json_object_set_int(struct json_object *obj, int new_value)
unsigned int ucs_char
Definition: json_tokener.h:116
@ json_tokener_error_parse_string
Definition: json_tokener.h:40
int size
Definition: printbuf.h:42
@ json_type_array
Definition: json_types.h:70
JSON_EXPORT struct json_object * json_object_iter_peek_value(const struct json_object_iterator *iter)
int lh_table_resize(struct lh_table *t, int new_size)
JSON_EXPORT struct json_object_iterator json_object_iter_end(const struct json_object *obj)
JSON_EXPORT int json_object_object_length(const struct json_object *obj)
JSON_EXPORT struct json_object * json_object_get(struct json_object *obj)
JSON_EXPORT struct json_tokener * json_tokener_new(void)
int() json_object_to_json_string_fn(struct json_object *jso, struct printbuf *pb, int level, int flags)
Definition: json_types.h:57
JSON_EXPORT int json_object_set_string_len(json_object *obj, const char *new_value, int len)
int lh_table_length(struct lh_table *t)
char * str
Definition: json_tokener.h:105
@ json_tokener_state_string
Definition: json_tokener.h:59
struct json_object * val
Definition: json_types.h:37
enum json_tokener_state state saved_state
Definition: json_tokener.h:85
int max_depth
Definition: json_tokener.h:107
lh_hash_fn * hash_fn
Definition: linkhash.h:140
@ json_type_string
Definition: json_types.h:71
JSON_EXPORT struct json_object * json_object_new_int(int32_t i)
unsigned int high_surrogate
Definition: json_tokener.h:116
struct lh_entry * head
Definition: linkhash.h:127
@ json_tokener_state_escape_unicode
Definition: json_tokener.h:61
#define JSON_EXPORT
Definition: printbuf.h:30
JSON_EXPORT int json_c_set_serialization_double_format(const char *double_format, int global_or_thread)
JSON_EXPORT struct json_object * json_object_new_array(void)
JSON_EXPORT int json_c_visit(json_object *jso, int future_flags, json_c_visit_userfunc *userfunc, void *userarg)
JSON_EXPORT int json_object_equal(struct json_object *obj1, struct json_object *obj2)
Core json-c API. Start here, or with json_tokener.h.
JSON_EXPORT int json_object_set_string(json_object *obj, const char *new_value)
Definition: json_tokener.h:83
JSON_EXPORT struct json_object * json_object_array_get_idx(const struct json_object *obj, size_t idx)
size_t array_list_length(struct array_list *al)
JSON_EXPORT struct json_object * json_tokener_parse_ex(struct json_tokener *tok, const char *str, int len)
JSON_EXPORT size_t json_object_array_length(const struct json_object *obj)
@ json_tokener_state_object_field_start
Definition: json_tokener.h:69
size_t length
Definition: arraylist.h:34
JSON_EXPORT int json_object_set_uint64(struct json_object *obj, uint64_t new_value)
char * key
Definition: json_types.h:36
JSON_EXPORT int64_t json_object_get_int64(const struct json_object *obj)
int k_is_constant
Definition: linkhash.h:95
struct lh_table * lh_kptr_table_new(int size, lh_entry_free_fn *free_fn)
json_tokener_error
Definition: json_tokener.h:26
JSON_EXPORT int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags)
Definition: json_object_iterator.h:42
@ json_type_boolean
Definition: json_types.h:66
@ json_tokener_error_parse_object_key_name
Definition: json_tokener.h:37
@ json_tokener_state_boolean
Definition: json_tokener.h:64
@ json_tokener_error_size
Definition: json_tokener.h:43
@ json_tokener_state_finish
Definition: json_tokener.h:53
size_t size
Definition: arraylist.h:35
@ json_tokener_state_array
Definition: json_tokener.h:66
JSON_EXPORT int json_object_object_add(struct json_object *obj, const char *key, struct json_object *val)
JSON_EXPORT int json_object_set_double(struct json_object *obj, double new_value)
JSON_EXPORT double json_object_get_double(const struct json_object *obj)
JSON_EXPORT struct json_object * json_object_from_file(const char *filename)
@ json_tokener_state_object_field_start_after_sep
Definition: json_tokener.h:76
int lh_table_delete(struct lh_table *t, const void *k)
const JSON_EXPORT char * json_type_to_name(enum json_type o_type)
int array_list_shrink(struct array_list *arr, size_t empty_slots)
JSON_EXPORT int json_object_is_type(const struct json_object *obj, enum json_type type)
struct lh_entry * prev
Definition: linkhash.h:107
char * obj_field_name
Definition: json_tokener.h:88
const void * k
Definition: linkhash.h:90
lh_equal_fn * equal_fn
Definition: linkhash.h:141
Definition: linkhash.h:85
char quote_char
Definition: json_tokener.h:117
JSON_EXPORT json_c_shallow_copy_fn json_c_shallow_copy_default
Definition: json_object.h:1041
const JSON_EXPORT char * json_object_to_json_string_ext(struct json_object *obj, int flags)
JSON_EXPORT struct json_object * json_object_new_double_s(double d, const char *ds)
enum json_tokener_error err
Definition: json_tokener.h:115
JSON_EXPORT void json_tokener_free(struct json_tokener *tok)
JSON_EXPORT struct json_object * json_object_new_boolean(json_bool b)
JSON_EXPORT struct json_object * json_object_from_fd(int fd)
int bpos
Definition: printbuf.h:41
@ json_tokener_state_number
Definition: json_tokener.h:65
@ json_tokener_error_parse_eof
Definition: json_tokener.h:31
@ json_tokener_state_start
Definition: json_tokener.h:52
Methods to parse an input string into a tree of json_object objects.
struct lh_table * lh_kchar_table_new(int size, lh_entry_free_fn *free_fn)
JSON_EXPORT void json_tokener_set_flags(struct json_tokener *tok, int flags)
int json_bool
Definition: json_types.h:42
struct lh_entry * lh_table_lookup_entry(struct lh_table *t, const void *k)
#define JSON_EXPORT
Definition: json_c_version.h:30
JSON_EXPORT int json_object_set_boolean(struct json_object *obj, json_bool new_value)
const JSON_EXPORT char * json_object_to_json_string(struct json_object *obj)
@ json_tokener_error_parse_null
Definition: json_tokener.h:33
@ json_type_null
Definition: json_types.h:65
JSON_EXPORT struct json_object * json_object_new_string_len(const char *s, const int len)
struct lh_entry * lh_table_lookup_entry_w_hash(struct lh_table *t, const void *k, const unsigned long h)
@ json_tokener_state_array_sep
Definition: json_tokener.h:68
char * buf
Definition: printbuf.h:40
JSON_EXPORT struct json_object * json_object_new_uint64(uint64_t i)
const JSON_EXPORT char * json_util_get_last_err(void)
void array_list_free(struct array_list *al)
@ json_tokener_state_escape_unicode_need_u
Definition: json_tokener.h:63
struct lh_entry * next
Definition: linkhash.h:103
int array_list_add(struct array_list *al, void *data)
JSON_EXPORT int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res)
@ json_tokener_error_depth
Definition: json_tokener.h:30
JSON_EXPORT void json_object_array_sort(struct json_object *jso, int(*sort_fn)(const void *, const void *))
@ json_tokener_state_comment_eol
Definition: json_tokener.h:57
JSON_EXPORT struct json_object_iterator json_object_iter_begin(struct json_object *obj)
const JSON_EXPORT char * json_object_to_json_string_length(struct json_object *obj, int flags, size_t *length)
Basic types used in a few places in json-c, but you should include "json_object.h" instead.
struct json_object * current
Definition: json_tokener.h:87
Definition: arraylist.h:31
@ json_tokener_error_parse_comment
Definition: json_tokener.h:41
JSON_EXPORT size_t json_tokener_get_parse_end(struct json_tokener *tok)
JSON_EXPORT int json_object_array_shrink(struct json_object *jso, int empty_slots)
const JSON_EXPORT char * json_object_iter_peek_name(const struct json_object_iterator *iter)
JSON_EXPORT int json_object_to_file(const char *filename, struct json_object *obj)
@ json_tokener_state_object_value_add
Definition: json_tokener.h:73
Internal methods for working with json_type_object objects. Although this is exposed by the json_obje...
JSON_EXPORT int printbuf_memappend(struct printbuf *p, const char *buf, int size)
JSON_EXPORT int json_object_to_fd(int fd, struct json_object *obj, int flags)
void * array_list_bsearch(const void **key, struct array_list *arr, int(*compar)(const void *, const void *))
struct array_list * array_list_new(array_list_free_fn *free_fn)
const void * v
Definition: linkhash.h:99
Internal methods for working with json_type_array objects. Although this is exposed by the json_objec...
void ** array
Definition: arraylist.h:33
Miscllaneous utility functions and macros.
json_tokener_state
Definition: json_tokener.h:49
JSON_EXPORT struct json_object * json_tokener_parse_verbose(const char *str, enum json_tokener_error *error)
JSON_EXPORT int sprintbuf(struct printbuf *p, const char *msg,...)
json_type
Definition: json_types.h:62
struct json_tokener_srec * stack
Definition: json_tokener.h:118
void lh_table_free(struct lh_table *t)
int array_list_del_idx(struct array_list *arr, size_t idx, size_t count)
@ json_tokener_error_parse_utf8_string
Definition: json_tokener.h:42
void() lh_entry_free_fn(struct lh_entry *e)
Definition: linkhash.h:72
int json_global_set_string_hash(const int h)
JSON_EXPORT int32_t json_object_get_int(const struct json_object *obj)
@ json_tokener_error_parse_boolean
Definition: json_tokener.h:34
int array_list_put_idx(struct array_list *al, size_t i, void *data)
const JSON_EXPORT char * json_tokener_error_desc(enum json_tokener_error jerr)
int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v, const unsigned long h, const unsigned opts)
const void * opaque_
Definition: json_object_iterator.h:44
JSON_EXPORT struct json_object * json_object_new_double(double d)
JSON_EXPORT void json_object_object_del(struct json_object *obj, const char *key)
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 *))
int st_pos
Definition: json_tokener.h:107
JSON_EXPORT json_object_to_json_string_fn json_object_userdata_to_json_string
Definition: json_object.h:323
JSON_EXPORT int json_parse_double(const char *buf, double *retval)
@ json_tokener_state_null
Definition: json_tokener.h:54
@ json_tokener_state_inf
Definition: json_tokener.h:77
JSON_EXPORT int json_parse_int64(const char *buf, int64_t *retval)
lh_entry_free_fn * free_fn
Definition: linkhash.h:139
int lh_table_insert(struct lh_table *t, const void *k, const void *v)
@ json_tokener_error_parse_object_value_sep
Definition: json_tokener.h:39