5#ifndef SPA_UTILS_JSON_UTILS_H
6#define SPA_UTILS_JSON_UTILS_H
93 const char *data,
size_t size,
char type,
bool relax)
98 if (res == -EPROTO && relax)
118 return sub.
cur + 1 - value;
140 if (res1 <= 0 && res1 != -ENOSPC)
143 if (res2 <= 0 || res1 != -ENOSPC)
151 int res, len = strlen(key) + 3;
161 const char *key,
char *value,
size_t maxlen)
188#define spa_json_make_str_array_unpack(maxlen,type,conv) \
190 struct spa_json iter; \
192 uint32_t count = 0; \
193 if (spa_json_begin_array_relax(&iter, arr, arr_len) <= 0) \
195 while (spa_json_get_string(&iter, v, sizeof(v)) > 0 && count < max) \
196 values[count++] = conv(v); \
201 uint32_t *values,
size_t max)
#define SPA_JSON_SAVE(iter)
Definition json-core.h:64
static int spa_json_parse_float(const char *val, int len, float *result)
Definition json-core.h:395
static int spa_json_parse_stringn(const char *val, int len, char *result, int maxlen)
Definition json-core.h:506
static int spa_json_begin_object(struct spa_json *iter, const char *data, size_t size)
Definition json.h:135
static int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)
Definition json.h:83
static void spa_json_enter(struct spa_json *iter, struct spa_json *sub)
Definition json-core.h:58
static int spa_json_begin_container(struct spa_json *iter, const char *data, size_t size, char type, bool relax)
Definition json.h:97
static int spa_json_get_int(struct spa_json *iter, int *res)
Definition json.h:53
static int spa_json_parse_bool(const char *val, int len, bool *result)
Definition json-core.h:472
static int spa_json_enter_object(struct spa_json *iter, struct spa_json *sub)
Definition json.h:127
static int spa_json_get_string(struct spa_json *iter, char *res, int maxlen)
Definition json.h:73
static int spa_json_begin(struct spa_json *iter, const char *data, size_t size, const char **val)
Definition json.h:36
static int spa_json_str_object_find(const char *obj, size_t obj_len, const char *key, char *value, size_t maxlen)
Definition json.h:165
static int spa_json_begin_array(struct spa_json *iter, const char *data, size_t size)
Definition json.h:188
static int spa_json_get_bool(struct spa_json *iter, bool *res)
Definition json.h:63
static int spa_json_object_find(struct spa_json *iter, const char *key, const char **value)
Definition json.h:153
#define spa_json_make_str_array_unpack(maxlen, type, conv)
Definition json.h:193
static int spa_json_parse_int(const char *val, int len, int *result)
Definition json-core.h:436
static int spa_json_next(struct spa_json *iter, const char **value)
Get the next token.
Definition json-core.h:71
static int spa_json_object_next(struct spa_json *iter, char *key, int maxkeylen, const char **value)
Definition json.h:140
static int spa_json_is_container(const char *val, int len)
Definition json-core.h:371
static void spa_json_init(struct spa_json *iter, const char *data, size_t size)
Definition json-core.h:51
static int spa_json_enter_array(struct spa_json *iter, struct spa_json *sub)
Definition json.h:180
static int spa_json_begin_object_relax(struct spa_json *iter, const char *data, size_t size)
Definition json.h:131
static int spa_json_get_float(struct spa_json *iter, float *res)
Definition json.h:43
static int spa_json_begin_array_relax(struct spa_json *iter, const char *data, size_t size)
Definition json.h:184
static int spa_json_str_array_uint32(const char *arr, size_t arr_len, uint32_t *values, size_t max)
Definition json.h:205
static int spa_json_container_len(struct spa_json *iter, const char *value, int len 1)
Return length of container at current position, starting at value.
Definition json.h:114
static bool spa_streq(const char *s1, const char *s2)
Definition string.h:41
#define SPA_UNUSED
Definition defs.h:307
Definition json-core.h:38
const char * cur
Definition json-core.h:39