3 Copyright (c) 2010 Serge A. Zaitsev
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 * JSON type identifier. Basic types are:
38 * o Other primitive: number, boolean (true/false) or null
49 /* Not enough tokens were provided */
50 JSMN_ERROR_NOMEM
= -1,
51 /* Invalid character inside JSON string */
52 JSMN_ERROR_INVAL
= -2,
53 /* The string is not a full JSON packet, more bytes expected */
58 * JSON token description.
59 * type type (object, array, string etc.)
60 * start start position in JSON data string
61 * end end position in JSON data string
68 #ifdef JSMN_PARENT_LINKS
74 * JSON parser. Contains an array of token blocks available. Also stores
75 * the string being parsed now and current position in that string
78 unsigned int pos
; /* offset in the JSON string */
79 unsigned int toknext
; /* next token to allocate */
80 int toksuper
; /* superior token node, e.g parent object or array */
84 * Create JSON parser over an array of tokens
86 void jsmn_init(jsmn_parser
*parser
);
89 * Run JSON parser. It parses a JSON data string into and array of tokens, each describing
90 * a single JSON object.
92 int jsmn_parse(jsmn_parser
*parser
, const char *js
, size_t len
,
93 jsmntok_t
*tokens
, unsigned int num_tokens
);
99 #endif /* __JSMN_H_ */