Linux Perf
jsmn.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __JSMN_H_
3 #define __JSMN_H_
4 
5 /*
6  * JSON type identifier. Basic types are:
7  * o Object
8  * o Array
9  * o String
10  * o Other primitive: number, boolean (true/false) or null
11  */
12 typedef enum {
17 } jsmntype_t;
18 
19 typedef enum {
20  /* Not enough tokens were provided */
22  /* Invalid character inside JSON string */
24  /* The string is not a full JSON packet, more bytes expected */
26  /* Everything was fine */
28 } jsmnerr_t;
29 
30 /*
31  * JSON token description.
32  * @param type type (object, array, string etc.)
33  * @param start start position in JSON data string
34  * @param end end position in JSON data string
35  */
36 typedef struct {
38  int start;
39  int end;
40  int size;
41 } jsmntok_t;
42 
43 /*
44  * JSON parser. Contains an array of token blocks available. Also stores
45  * the string being parsed now and current position in that string
46  */
47 typedef struct {
48  unsigned int pos; /* offset in the JSON string */
49  int toknext; /* next token to allocate */
50  int toksuper; /* superior token node, e.g parent object or array */
51 } jsmn_parser;
52 
53 /*
54  * Create JSON parser over an array of tokens
55  */
57 
58 /*
59  * Run JSON parser. It parses a JSON data string into and array of tokens,
60  * each describing a single JSON object.
61  */
62 jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js,
63  size_t len,
64  jsmntok_t *tokens, unsigned int num_tokens);
65 
66 const char *jsmn_strerror(jsmnerr_t err);
67 
68 #endif /* __JSMN_H_ */
Definition: jsmn.h:36
jsmntype_t
Definition: jsmn.h:12
int int err
Definition: 5sec.c:44
const char * jsmn_strerror(jsmnerr_t err)
Definition: jsmn.c:299
jsmntype_t type
Definition: jsmn.h:37
jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
Definition: jsmn.c:173
void jsmn_init(jsmn_parser *parser)
Definition: jsmn.c:292
int toksuper
Definition: jsmn.h:50
int start
Definition: jsmn.h:38
int end
Definition: jsmn.h:39
int toknext
Definition: jsmn.h:49
int size
Definition: jsmn.h:40
unsigned int pos
Definition: jsmn.h:48
jsmnerr_t
Definition: jsmn.h:19