PipeWire 1.2.6
Loading...
Searching...
No Matches
JSON

Relaxed JSON variant parsing More...

Files

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)   ((struct spa_json) { (data), (data)+(size), 0, 0, 0 })
 
#define SPA_JSON_ENTER(iter)   ((struct spa_json) { (iter)->cur, (iter)->end, (iter), (iter)->state & 0xff0, 0 })
 
#define SPA_JSON_SAVE(iter)   ((struct spa_json) { (iter)->cur, (iter)->end, NULL, (iter)->state, 0 })
 

Functions

static void spa_json_init (struct spa_json *iter, const char *data, size_t size)
 
static void spa_json_enter (struct spa_json *iter, struct spa_json *sub)
 
static int spa_json_next (struct spa_json *iter, const char **value)
 Get the next token.
 
static bool spa_json_get_error (struct spa_json *iter, const char *start, struct spa_error_location *loc)
 Return it there was a parse error, and its possible location.
 
static int spa_json_enter_container (struct spa_json *iter, struct spa_json *sub, char type)
 
static int spa_json_is_container (const char *val, int len)
 
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.
 
static int spa_json_is_object (const char *val, int len)
 
static int spa_json_enter_object (struct spa_json *iter, struct spa_json *sub)
 
static bool spa_json_is_array (const char *val, int len)
 
static int spa_json_enter_array (struct spa_json *iter, struct spa_json *sub)
 
static bool spa_json_is_null (const char *val, int len)
 
static int spa_json_parse_float (const char *val, int len, float *result)
 
static bool spa_json_is_float (const char *val, int len)
 
static int spa_json_get_float (struct spa_json *iter, float *res)
 
static char * spa_json_format_float (char *str, int size, float val)
 
static int spa_json_parse_int (const char *val, int len, int *result)
 
static bool spa_json_is_int (const char *val, int len)
 
static int spa_json_get_int (struct spa_json *iter, int *res)
 
static bool spa_json_is_true (const char *val, int len)
 
static bool spa_json_is_false (const char *val, int len)
 
static bool spa_json_is_bool (const char *val, int len)
 
static int spa_json_parse_bool (const char *val, int len, bool *result)
 
static int spa_json_get_bool (struct spa_json *iter, bool *res)
 
static bool spa_json_is_string (const char *val, int len)
 
static int spa_json_parse_hex (const char *p, int num, uint32_t *res)
 
static int spa_json_parse_stringn (const char *val, int len, char *result, int maxlen)
 
static int spa_json_parse_string (const char *val, int len, char *result)
 
static int spa_json_get_string (struct spa_json *iter, char *res, int maxlen)
 
static int spa_json_encode_string (char *str, int size, const char *val)
 

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 )   ((struct spa_json) { (data), (data)+(size), 0, 0, 0 })

◆ SPA_JSON_ENTER

#define SPA_JSON_ENTER ( iter)    ((struct spa_json) { (iter)->cur, (iter)->end, (iter), (iter)->state & 0xff0, 0 })

◆ SPA_JSON_SAVE

#define SPA_JSON_SAVE ( iter)    ((struct spa_json) { (iter)->cur, (iter)->end, NULL, (iter)->state, 0 })

Function Documentation

◆ spa_json_init()

static void spa_json_init ( struct spa_json * iter,
const char * data,
size_t size )
inlinestatic

◆ spa_json_enter()

static void spa_json_enter ( struct spa_json * iter,
struct spa_json * sub )
inlinestatic

◆ spa_json_next()

static int spa_json_next ( struct spa_json * iter,
const char ** value )
inlinestatic

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()

static bool spa_json_get_error ( struct spa_json * iter,
const char * start,
struct spa_error_location * loc )
inlinestatic

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

Since
1.1.0

◆ spa_json_enter_container()

static int spa_json_enter_container ( struct spa_json * iter,
struct spa_json * sub,
char type )
inlinestatic

◆ spa_json_is_container()

static int spa_json_is_container ( const char * val,
int len )
inlinestatic

◆ spa_json_container_len()

static int spa_json_container_len ( struct spa_json * iter,
const char * value,
int len 1 )
inlinestatic

Return length of container at current position, starting at value.

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

◆ spa_json_is_object()

static int spa_json_is_object ( const char * val,
int len )
inlinestatic

◆ spa_json_enter_object()

static int spa_json_enter_object ( struct spa_json * iter,
struct spa_json * sub )
inlinestatic

◆ spa_json_is_array()

static bool spa_json_is_array ( const char * val,
int len )
inlinestatic

◆ spa_json_enter_array()

static int spa_json_enter_array ( struct spa_json * iter,
struct spa_json * sub )
inlinestatic

◆ spa_json_is_null()

static bool spa_json_is_null ( const char * val,
int len )
inlinestatic

◆ spa_json_parse_float()

static int spa_json_parse_float ( const char * val,
int len,
float * result )
inlinestatic

◆ spa_json_is_float()

static bool spa_json_is_float ( const char * val,
int len )
inlinestatic

◆ spa_json_get_float()

static int spa_json_get_float ( struct spa_json * iter,
float * res )
inlinestatic

◆ spa_json_format_float()

static char * spa_json_format_float ( char * str,
int size,
float val )
inlinestatic

◆ spa_json_parse_int()

static int spa_json_parse_int ( const char * val,
int len,
int * result )
inlinestatic

◆ spa_json_is_int()

static bool spa_json_is_int ( const char * val,
int len )
inlinestatic

◆ spa_json_get_int()

static int spa_json_get_int ( struct spa_json * iter,
int * res )
inlinestatic

◆ spa_json_is_true()

static bool spa_json_is_true ( const char * val,
int len )
inlinestatic

◆ spa_json_is_false()

static bool spa_json_is_false ( const char * val,
int len )
inlinestatic

◆ spa_json_is_bool()

static bool spa_json_is_bool ( const char * val,
int len )
inlinestatic

◆ spa_json_parse_bool()

static int spa_json_parse_bool ( const char * val,
int len,
bool * result )
inlinestatic

◆ spa_json_get_bool()

static int spa_json_get_bool ( struct spa_json * iter,
bool * res )
inlinestatic

◆ spa_json_is_string()

static bool spa_json_is_string ( const char * val,
int len )
inlinestatic

◆ spa_json_parse_hex()

static int spa_json_parse_hex ( const char * p,
int num,
uint32_t * res )
inlinestatic

◆ spa_json_parse_stringn()

static int spa_json_parse_stringn ( const char * val,
int len,
char * result,
int maxlen )
inlinestatic

◆ spa_json_parse_string()

static int spa_json_parse_string ( const char * val,
int len,
char * result )
inlinestatic

◆ spa_json_get_string()

static int spa_json_get_string ( struct spa_json * iter,
char * res,
int maxlen )
inlinestatic

◆ spa_json_encode_string()

static int spa_json_encode_string ( char * str,
int size,
const char * val )
inlinestatic