libschc
jsmn.h
Go to the documentation of this file.
1 #ifndef __JSMN_H_
2 #define __JSMN_H_
3 
4 #include <stddef.h>
5 #include "schc.h"
6 
7 #if CLICK
8 #include <click/config.h>
9 #endif
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
22 typedef enum {
28 } jsmntype_t;
29 
30 enum jsmnerr {
31  /* Not enough tokens were provided */
33  /* Invalid character inside JSON string */
35  /* The string is not a full JSON packet, more bytes expected */
37 };
38 
45 typedef struct {
47  int start;
48  int end;
49  int size;
50 #ifdef JSMN_PARENT_LINKS
51  int parent;
52 #endif
53 } jsmntok_t;
54 
59 typedef struct {
60  unsigned int pos; /* offset in the JSON string */
61  unsigned int toknext; /* next token to allocate */
62  int toksuper; /* superior token node, e.g parent object or array */
63 } jsmn_parser;
64 
68 void jsmn_init(jsmn_parser *parser);
69 
74 int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
75  jsmntok_t *tokens, unsigned int num_tokens);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /* __JSMN_H_ */
JSMN_ERROR_NOMEM
Definition: jsmn.h:32
jsmn_parser::pos
unsigned int pos
Definition: jsmn.h:60
jsmntype_t
jsmntype_t
JSON type identifier.
Definition: jsmn.h:22
jsmn_init
void jsmn_init(jsmn_parser *parser)
Create JSON parser over an array of tokens.
Definition: jsmn.c:309
JSMN_UNDEFINED
Definition: jsmn.h:23
JSMN_PRIMITIVE
Definition: jsmn.h:27
JSMN_ERROR_INVAL
Definition: jsmn.h:34
JSMN_STRING
Definition: jsmn.h:26
schc.h
jsmn_parse
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:151
jsmn_parser
JSON parser.
Definition: jsmn.h:59
jsmn_parser::toksuper
int toksuper
Definition: jsmn.h:62
jsmntok_t::start
int start
Definition: jsmn.h:47
jsmntok_t::end
int end
Definition: jsmn.h:48
jsmntok_t::type
jsmntype_t type
Definition: jsmn.h:46
JSMN_OBJECT
Definition: jsmn.h:24
jsmntok_t::size
int size
Definition: jsmn.h:49
JSMN_ARRAY
Definition: jsmn.h:25
jsmnerr
jsmnerr
Definition: jsmn.h:30
jsmn_parser::toknext
unsigned int toknext
Definition: jsmn.h:61
JSMN_ERROR_PART
Definition: jsmn.h:36
jsmntok_t
JSON token description.
Definition: jsmn.h:45