summaryrefslogtreecommitdiff
path: root/jsmn.h
blob: 06f2f516a1eb18a360ff519337be7c484db99e38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef __JSMN_H_
#define __JSMN_H_

/**
 * JSON type identifier. Basic types are:
 * 	o Object
 * 	o Array
 * 	o String
 * 	o Number
 * 	o Other 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_ */