This documentation is under development!

jsmn

jsmn#

Defines

JSMN_API#

Typedefs

typedef struct jsmntok jsmntok_t#

JSON token description. type type (object, array, string etc.) start start position in JSON data string end end position in JSON data string

typedef struct jsmn_parser jsmn_parser#

JSON parser. Contains an array of token blocks available. Also stores the string being parsed now and current position in that string.

Enums

enum jsmntype_t#

JSON type identifier. Basic types are: o Object o Array o String o Other primitive: number, boolean (true/false) or null

Values:

enumerator JSMN_UNDEFINED#
enumerator JSMN_OBJECT#
enumerator JSMN_ARRAY#
enumerator JSMN_STRING#
enumerator JSMN_PRIMITIVE#
enum jsmnerr#

Values:

enumerator JSMN_ERROR_NOMEM#
enumerator JSMN_ERROR_INVAL#
enumerator JSMN_ERROR_PART#

Functions

void jsmn_init(jsmn_parser *parser)#

Create JSON parser over an array of tokens

Creates a new parser based over a given buffer with an array of tokens available.

int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, jsmntok_t *tokens, const unsigned int num_tokens)#

Run JSON parser. It parses a JSON data string into and array of tokens, each describing a single JSON object.

Parse JSON string and fill tokens.

static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, const size_t num_tokens)#

Allocates a fresh unused token from the token pool.

static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type, const int start, const int end)#

Fills token type and boundaries.

static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, const size_t len, jsmntok_t *tokens, const size_t num_tokens)#

Fills next available token with JSON primitive.

static int jsmn_parse_string(jsmn_parser *parser, const char *js, const size_t len, jsmntok_t *tokens, const size_t num_tokens)#

Fills next token with JSON string.

struct jsmntok#
#include <jsmn.h>

JSON token description. type type (object, array, string etc.) start start position in JSON data string end end position in JSON data string

Public Members

jsmntype_t type#
int start#
int end#
int size#
struct jsmn_parser
#include <jsmn.h>

JSON parser. Contains an array of token blocks available. Also stores the string being parsed now and current position in that string.

Public Members

unsigned int pos#
unsigned int toknext#
int toksuper#