My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
jsmn.h
Go to the documentation of this file.
1 
23 #ifndef __JSMN_H_
24 #define __JSMN_H_
25 
26 #include <stddef.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 
33 
41 typedef enum {
47 } jsmntype_t;
48 
49 enum jsmnerr {
50  /* Not enough tokens were provided */
52  /* Invalid character inside JSON string */
54  /* The string is not a full JSON packet, more bytes expected */
56 };
57 
64 typedef struct {
65  jsmntype_t type;
66  int start;
67  int end;
68  int size;
69 #ifdef JSMN_PARENT_LINKS
70  int parent;
71 #endif
72 } jsmntok_t;
73 
78 typedef struct {
79  unsigned int pos; /* offset in the JSON string */
80  unsigned int toknext; /* next token to allocate */
81  int toksuper; /* superior token node, e.g parent object or array */
82 } jsmn_parser;
83 
87 void jsmn_init(jsmn_parser *parser);
88 
93 int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
94  jsmntok_t *tokens, unsigned int num_tokens);
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif /* __JSMN_H_ */
JSON token description.
Definition: jsmn.h:61
jsmntype_t
JSON type identifier.
Definition: jsmn.h:38
JSON parser.
Definition: jsmn.h:75
void jsmn_init(jsmn_parser *parser)
Create JSON parser over an array of tokens.
Definition: jsmn.c:331
int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
Run JSON parser.
Definition: jsmn.c:173
static const char tokens[256]
Definition: http_parser.c:208
jsmnerr
Definition: jsmn.h:46