PipeWire: JSON

PipeWire 1.4.9

Loading...
Searching...
No Matches
JSON
SPA » Utilities

Relaxed JSON variant parsing. More...

## Files
file | json-core.h
| spa/utils/json-core.h
file | json.h
| spa/utils/json.h

## Data Structures
struct | spa_json

## Macros
#define | SPA_JSON_ERROR_FLAG 0x100
#define | SPA_JSON_INIT(data, size)
#define | SPA_JSON_ENTER(iter)
#define | SPA_JSON_SAVE(iter)
#define | SPA_JSON_START(iter, p)
#define | spa_json_make_str_array_unpack(maxlen, type, conv)

## Functions
SPA_API_JSON void | spa_json_init (struct spa_json *iter, const char *data, size_t size)
SPA_API_JSON void | spa_json_enter (struct spa_json *iter, struct spa_json *sub)
SPA_API_JSON void | spa_json_save (struct spa_json *iter, struct spa_json *save)
SPA_API_JSON void | spa_json_start (struct spa_json *iter, struct spa_json *sub, const char *pos)
SPA_API_JSON int | spa_json_next (struct spa_json *iter, const char **value)
| Get the next token.
SPA_API_JSON bool | spa_json_get_error (struct spa_json *iter, const char *start, struct spa_error_location *loc)
| Return if there was a parse error, and its possible location.
SPA_API_JSON int | spa_json_is_container (const char *val, int len)
SPA_API_JSON int | spa_json_is_object (const char *val, int len)
SPA_API_JSON bool | spa_json_is_array (const char *val, int len)
SPA_API_JSON bool | spa_json_is_null (const char *val, int len)
SPA_API_JSON int | spa_json_parse_float (const char *val, int len, float *result)
SPA_API_JSON bool | spa_json_is_float (const char *val, int len)
SPA_API_JSON char * | spa_json_format_float (char *str, int size, float val)
SPA_API_JSON int | spa_json_parse_int (const char *val, int len, int *result)
SPA_API_JSON bool | spa_json_is_int (const char *val, int len)
SPA_API_JSON bool | spa_json_is_true (const char *val, int len)
SPA_API_JSON bool | spa_json_is_false (const char *val, int len)
SPA_API_JSON bool | spa_json_is_bool (const char *val, int len)
SPA_API_JSON int | spa_json_parse_bool (const char *val, int len, bool *result)
SPA_API_JSON bool | spa_json_is_string (const char *val, int len)
SPA_API_JSON int | spa_json_parse_hex (const char *p, int num, uint32_t *res)
SPA_API_JSON int | spa_json_parse_stringn (const char *val, int len, char *result, int maxlen)
SPA_API_JSON int | spa_json_parse_string (const char *val, int len, char *result)
SPA_API_JSON int | spa_json_encode_string (char *str, int size, const char *val)
SPA_API_JSON_UTILS int | spa_json_begin (struct spa_json *iter, const char *data, size_t size, const char **val)
SPA_API_JSON_UTILS int | spa_json_get_float (struct spa_json *iter, float *res)
SPA_API_JSON_UTILS int | spa_json_get_int (struct spa_json *iter, int *res)
SPA_API_JSON_UTILS int | spa_json_get_bool (struct spa_json *iter, bool *res)
SPA_API_JSON_UTILS int | spa_json_get_string (struct spa_json *iter, char *res, int maxlen)
SPA_API_JSON_UTILS int | spa_json_enter_container (struct spa_json *iter, struct spa_json *sub, char type)
SPA_API_JSON_UTILS int | spa_json_begin_container (struct spa_json *iter, const char *data, size_t size, char type, bool relax)
SPA_API_JSON_UTILS 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.
SPA_API_JSON_UTILS int | spa_json_enter_object (struct spa_json *iter, struct spa_json *sub)
SPA_API_JSON_UTILS int | spa_json_begin_object_relax (struct spa_json *iter, const char *data, size_t size)
SPA_API_JSON_UTILS int | spa_json_begin_object (struct spa_json *iter, const char *data, size_t size)
SPA_API_JSON_UTILS int | spa_json_object_next (struct spa_json *iter, char *key, int maxkeylen, const char **value)
SPA_API_JSON_UTILS int | spa_json_object_find (struct spa_json *iter, const char *key, const char **value)
SPA_API_JSON_UTILS int | spa_json_str_object_find (const char *obj, size_t obj_len, const char *key, char *value, size_t maxlen)
SPA_API_JSON_UTILS int | spa_json_enter_array (struct spa_json *iter, struct spa_json *sub)
SPA_API_JSON_UTILS int | spa_json_begin_array_relax (struct spa_json *iter, const char *data, size_t size)
SPA_API_JSON_UTILS int | spa_json_begin_array (struct spa_json *iter, const char *data, size_t size)
SPA_API_JSON_UTILS int | spa_json_str_array_uint32 (const char *arr, size_t arr_len, uint32_t *values, size_t max)

## Detailed Description

Relaxed JSON variant parsing.

## Macro Definition Documentation

## ◆ SPA_JSON_ERROR_FLAG

#define SPA_JSON_ERROR_FLAG 0x100

## ◆ SPA_JSON_INIT

#define SPA_JSON_INIT | ( |  | data,
|  |  | size )

Value:
((struct spa_json) { (data), (data)+(size), NULL, 0, 0 })
spa_json
Definition json-core.h:48

## ◆ SPA_JSON_ENTER

#define SPA_JSON_ENTER | ( |  | iter | ) |

Value:
((struct spa_json) { (iter)->cur, (iter)->end, (iter), (iter)->state & 0xff0, 0 })

## ◆ SPA_JSON_SAVE

#define SPA_JSON_SAVE | ( |  | iter | ) |

Value:
((struct spa_json) { (iter)->cur, (iter)->end, NULL, (iter)->state, 0 })

## ◆ SPA_JSON_START

#define SPA_JSON_START | ( |  | iter,
|  |  | p )

Value:
((struct spa_json) { (p), (iter)->end, NULL, 0, 0 })

## ◆ spa_json_make_str_array_unpack

#define spa_json_make_str_array_unpack | ( |  | maxlen,
|  |  | type,
|  |  | conv )

## Function Documentation

## ◆ spa_json_init()

SPA_API_JSON void spa_json_init | ( | struct spa_json * | iter,
|  | const char * | data,
|  | size_t | size )

## ◆ spa_json_enter()

SPA_API_JSON void spa_json_enter | ( | struct spa_json * | iter,
|  | struct spa_json * | sub )

## ◆ spa_json_save()

SPA_API_JSON void spa_json_save | ( | struct spa_json * | iter,
|  | struct spa_json * | save )

## ◆ spa_json_start()

SPA_API_JSON void spa_json_start | ( | struct spa_json * | iter,
|  | struct spa_json * | sub,
|  | const char * | pos )

## ◆ spa_json_next()

SPA_API_JSON int spa_json_next | ( | struct spa_json * | iter,
|  | const char ** | value )

Get the next token.

value points to the token and the return value is the length. Returns -1 on parse error, 0 on end of input.

## ◆ spa_json_get_error()

SPA_API_JSON bool spa_json_get_error | ( | struct spa_json * | iter,
|  | const char * | start,
|  | struct spa_error_location * | loc )

Return if there was a parse error, and its possible location.

Since
  1.1.0

## ◆ spa_json_is_container()

SPA_API_JSON int spa_json_is_container | ( | const char * | val,
|  | int | len )

## ◆ spa_json_is_object()

SPA_API_JSON int spa_json_is_object | ( | const char * | val,
|  | int | len )

## ◆ spa_json_is_array()

SPA_API_JSON bool spa_json_is_array | ( | const char * | val,
|  | int | len )

## ◆ spa_json_is_null()

SPA_API_JSON bool spa_json_is_null | ( | const char * | val,
|  | int | len )

## ◆ spa_json_parse_float()

SPA_API_JSON int spa_json_parse_float | ( | const char * | val,
|  | int | len,
|  | float * | result )

## ◆ spa_json_is_float()

SPA_API_JSON bool spa_json_is_float | ( | const char * | val,
|  | int | len )

## ◆ spa_json_format_float()

SPA_API_JSON char * spa_json_format_float | ( | char * | str,
|  | int | size,
|  | float | val )

## ◆ spa_json_parse_int()

SPA_API_JSON int spa_json_parse_int | ( | const char * | val,
|  | int | len,
|  | int * | result )

## ◆ spa_json_is_int()

SPA_API_JSON bool spa_json_is_int | ( | const char * | val,
|  | int | len )

## ◆ spa_json_is_true()

SPA_API_JSON bool spa_json_is_true | ( | const char * | val,
|  | int | len )

## ◆ spa_json_is_false()

SPA_API_JSON bool spa_json_is_false | ( | const char * | val,
|  | int | len )

## ◆ spa_json_is_bool()

SPA_API_JSON bool spa_json_is_bool | ( | const char * | val,
|  | int | len )

## ◆ spa_json_parse_bool()

SPA_API_JSON int spa_json_parse_bool | ( | const char * | val,
|  | int | len,
|  | bool * | result )

## ◆ spa_json_is_string()

SPA_API_JSON bool spa_json_is_string | ( | const char * | val,
|  | int | len )

## ◆ spa_json_parse_hex()

SPA_API_JSON int spa_json_parse_hex | ( | const char * | p,
|  | int | num,
|  | uint32_t * | res )

## ◆ spa_json_parse_stringn()

SPA_API_JSON int spa_json_parse_stringn | ( | const char * | val,
|  | int | len,
|  | char * | result,
|  | int | maxlen )

## ◆ spa_json_parse_string()

SPA_API_JSON int spa_json_parse_string | ( | const char * | val,
|  | int | len,
|  | char * | result )

## ◆ spa_json_encode_string()

SPA_API_JSON int spa_json_encode_string | ( | char * | str,
|  | int | size,
|  | const char * | val )

## ◆ spa_json_begin()

SPA_API_JSON_UTILS int spa_json_begin | ( | struct spa_json * | iter,
|  | const char * | data,
|  | size_t | size,
|  | const char ** | val )

## ◆ spa_json_get_float()

SPA_API_JSON_UTILS int spa_json_get_float | ( | struct spa_json * | iter,
|  | float * | res )

## ◆ spa_json_get_int()

SPA_API_JSON_UTILS int spa_json_get_int | ( | struct spa_json * | iter,
|  | int * | res )

## ◆ spa_json_get_bool()

SPA_API_JSON_UTILS int spa_json_get_bool | ( | struct spa_json * | iter,
|  | bool * | res )

## ◆ spa_json_get_string()

SPA_API_JSON_UTILS int spa_json_get_string | ( | struct spa_json * | iter,
|  | char * | res,
|  | int | maxlen )

## ◆ spa_json_enter_container()

SPA_API_JSON_UTILS int spa_json_enter_container | ( | struct spa_json * | iter,
|  | struct spa_json * | sub,
|  | char | type )

## ◆ spa_json_begin_container()

SPA_API_JSON_UTILS int spa_json_begin_container | ( | struct spa_json * | iter,
|  | const char * | data,
|  | size_t | size,
|  | char | type,
|  | bool | relax )

## ◆ spa_json_container_len()

SPA_API_JSON_UTILS 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.

Returns
  Length of container including {} or [], or 0 on error.

## ◆ spa_json_enter_object()

SPA_API_JSON_UTILS int spa_json_enter_object | ( | struct spa_json * | iter,
|  | struct spa_json * | sub )

## ◆ spa_json_begin_object_relax()

SPA_API_JSON_UTILS int spa_json_begin_object_relax | ( | struct spa_json * | iter,
|  | const char * | data,
|  | size_t | size )

## ◆ spa_json_begin_object()

SPA_API_JSON_UTILS int spa_json_begin_object | ( | struct spa_json * | iter,
|  | const char * | data,
|  | size_t | size )

## ◆ spa_json_object_next()

SPA_API_JSON_UTILS int spa_json_object_next | ( | struct spa_json * | iter,
|  | char * | key,
|  | int | maxkeylen,
|  | const char ** | value )

## ◆ spa_json_object_find()

SPA_API_JSON_UTILS int spa_json_object_find | ( | struct spa_json * | iter,
|  | const char * | key,
|  | const char ** | value )

## ◆ spa_json_str_object_find()

SPA_API_JSON_UTILS int spa_json_str_object_find | ( | const char * | obj,
|  | size_t | obj_len,
|  | const char * | key,
|  | char * | value,
|  | size_t | maxlen )

## ◆ spa_json_enter_array()

SPA_API_JSON_UTILS int spa_json_enter_array | ( | struct spa_json * | iter,
|  | struct spa_json * | sub )

## ◆ spa_json_begin_array_relax()

SPA_API_JSON_UTILS int spa_json_begin_array_relax | ( | struct spa_json * | iter,
|  | const char * | data,
|  | size_t | size )

## ◆ spa_json_begin_array()

SPA_API_JSON_UTILS int spa_json_begin_array | ( | struct spa_json * | iter,
|  | const char * | data,
|  | size_t | size )

## ◆ spa_json_str_array_uint32()

SPA_API_JSON_UTILS int spa_json_str_array_uint32 | ( | const char * | arr,
|  | size_t | arr_len,
|  | uint32_t * | values,
|  | size_t | max )