1. Mathias Brossard
  2. jsmn

Source

jsmn / jsmn.h

#ifndef __JSMN_H_
#define __JSMN_H_

/**
 * JSON type identifier. Basic types are:
 * 	o Object
 * 	o Array
 * 	o String
 * 	o Number
 * 	o Primitive: boolean (true/false) or null
 */
typedef enum {
	JSON_OTHER = 0,
	JSON_OBJECT,
	JSON_ARRAY,
	JSON_STRING,
	JSON_NUMBER
} jsontype_t;

/**
 * JSON token description.
 * @param		type	type (object, array, string etc.)
 * @param		start	start position in JSON data string
 * @param		end		end position in JSON data string
 */
typedef struct {
	jsontype_t type;
	int start;
	int end;
} jsontok_t;

/**
 * Run JSON parser. It parses a JSON data string into and array of tokens, each describing
 * a single JSON object.
 */
int jsmn_parse(const unsigned char *js, jsontok_t *tokens, size_t num_tokens, int **errpos);

#endif /* __JSMN_H_ */