My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
jsmn.h
Go to the documentation of this file.
1 /*
2 START OF LICENSE STUB
3  DeDOS: Declarative Dispersion-Oriented Software
4  Copyright (C) 2017 University of Pennsylvania, Georgetown University
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 END OF LICENSE STUB
19 */
20 #ifndef __JSMN_H_
21 #define __JSMN_H_
22 
23 #include <stddef.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 
38 typedef enum {
44 } jsmntype_t;
45 
46 enum jsmnerr {
47  /* Not enough tokens were provided */
49  /* Invalid character inside JSON string */
51  /* The string is not a full JSON packet, more bytes expected */
53 };
54 
61 typedef struct {
63  int start;
64  int end;
65  int size;
66 #ifdef JSMN_PARENT_LINKS
67  int parent;
68 #endif
69 } jsmntok_t;
70 
75 typedef struct {
76  unsigned int pos; /* offset in the JSON string */
77  unsigned int toknext; /* next token to allocate */
78  int toksuper; /* superior token node, e.g parent object or array */
79 } jsmn_parser;
80 
84 void jsmn_init(jsmn_parser *parser);
85 
90 int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
91  jsmntok_t *tokens, unsigned int num_tokens);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* __JSMN_H_ */
JSON token description.
Definition: jsmn.h:61
unsigned int toknext
Definition: jsmn.h:77
jsmntype_t
JSON type identifier.
Definition: jsmn.h:38
jsmntype_t type
Definition: jsmn.h:62
JSON parser.
Definition: jsmn.h:75
int toksuper
Definition: jsmn.h:78
int start
Definition: jsmn.h:63
void jsmn_init(jsmn_parser *parser)
Create JSON parser over an array of tokens.
Definition: jsmn.c:331
int end
Definition: jsmn.h:64
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
int size
Definition: jsmn.h:65
unsigned int pos
Definition: jsmn.h:76
static const char tokens[256]
Definition: http_parser.c:208
jsmnerr
Definition: jsmn.h:46