Types

JSON data types. More...

Data Structures

struct  gos_json_tok_t
 Parse JSON token. More...
 
struct  gos_json_parse_config_t
 JSON parser configuration. More...
 

Typedefs

typedef void * gos_json_parse_context_t
 Context of JSON parsing.
 
typedef gos_result_t(* gos_json_parse_reader_t) (void *user, void *data, uint32_t max_length, uint32_t *bytes_read)
 Reader callback. More...
 
typedef gos_result_t(* gos_json_token_callback_t) (void *user, gos_json_parse_context_t *context, gos_json_tok_t *tok)
 Allocate token callback. More...
 

Enumerations

enum  gos_json_type_t {
  GOS_JSON_TYPE_ARRAY,
  GOS_JSON_TYPE_OBJECT,
  GOS_JSON_TYPE_STRING,
  GOS_JSON_TYPE_BOOLEAN,
  GOS_JSON_TYPE_INTEGER,
  GOS_JSON_TYPE_INTEGER64,
  GOS_JSON_TYPE_FLOAT,
  GOS_JSON_TYPE_NULL
}
 JSON token type. More...
 
enum  gos_json_parse_flag_t { JSON_FLAG_STRINGS_INLINE = (1 << 0) }
 

Detailed Description

JSON data types.

Typedef Documentation

◆ gos_json_parse_reader_t

typedef gos_result_t(* gos_json_parse_reader_t) (void *user, void *data, uint32_t max_length, uint32_t *bytes_read)

Reader callback.

This is an optional callback that is called to read more JSON formatted data.

If there is no more data to be read, set bytes_read to 0 which tells the parser to stop calling this callback.

Parameters
userOptional pointer to user data, passed to gos_json_parse_chunked(), leave NULL if unused
dataBuffer to hold read data
max_lengthLength of given buffer
bytes_readNumber of bytes actually read, set to 0 if no more data available
Returns
gos_result_t result of api call

◆ gos_json_token_callback_t

typedef gos_result_t(* gos_json_token_callback_t) (void *user, gos_json_parse_context_t *context, gos_json_tok_t *tok)

Allocate token callback.

This is called before every token is allocated. This callback should return GOS_SUCCESS if the token should be allocated, GOS_ABORTED if the token should NOT be allocated, anything else will cause the parser to fail.

Parameters
userOptional pointer to user data, passed to gos_json_parse_chunked(), leave NULL if unused
contextParser context pointer
tokThe token that may be allocated
Returns
GOS_SUCCESS if token should be allocated, GOS_ABORTED if token should NOT be allocated, anything else is a failure

Enumeration Type Documentation

◆ gos_json_parse_flag_t

JSON parsing flags

Enumerator
JSON_FLAG_STRINGS_INLINE 

Only reference strings in json tokens, do not create copy.

Note
: The string values will only persist for as long as the parsed buffer is valid.

◆ gos_json_type_t

JSON token type.

See this tutorial for more info.

Enumerator
GOS_JSON_TYPE_ARRAY 

an ordered sequence of values

GOS_JSON_TYPE_OBJECT 

an unordered collection of key:value pairs

GOS_JSON_TYPE_STRING 

double-quoted Unicode with backslash escaping

GOS_JSON_TYPE_BOOLEAN 

true or false

GOS_JSON_TYPE_INTEGER 

32bit integer

GOS_JSON_TYPE_INTEGER64 

64bit integer

GOS_JSON_TYPE_FLOAT 

floating point number (returned as a string)

GOS_JSON_TYPE_NULL 

empty