My Project
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
src
common
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
{
42
JSMN_UNDEFINED
= 0,
43
JSMN_OBJECT
= 1,
44
JSMN_ARRAY
= 2,
45
JSMN_STRING
= 3,
46
JSMN_PRIMITIVE
= 4
47
}
jsmntype_t
;
48
49
enum
jsmnerr
{
50
/* Not enough tokens were provided */
51
JSMN_ERROR_NOMEM
= -1,
52
/* Invalid character inside JSON string */
53
JSMN_ERROR_INVAL
= -2,
54
/* The string is not a full JSON packet, more bytes expected */
55
JSMN_ERROR_PART
= -3
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_ */
jsmntok_t
JSON token description.
Definition:
jsmn.h:61
JSMN_STRING
Definition:
jsmn.h:42
JSMN_PRIMITIVE
Definition:
jsmn.h:43
JSMN_ARRAY
Definition:
jsmn.h:41
jsmntype_t
jsmntype_t
JSON type identifier.
Definition:
jsmn.h:38
JSMN_ERROR_INVAL
Definition:
jsmn.h:50
JSMN_ERROR_PART
Definition:
jsmn.h:52
jsmn_parser
JSON parser.
Definition:
jsmn.h:75
JSMN_ERROR_NOMEM
Definition:
jsmn.h:48
JSMN_OBJECT
Definition:
jsmn.h:40
jsmn_init
void jsmn_init(jsmn_parser *parser)
Create JSON parser over an array of tokens.
Definition:
jsmn.c:331
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:173
JSMN_UNDEFINED
Definition:
jsmn.h:39
tokens
static const char tokens[256]
Definition:
http_parser.c:208
jsmnerr
jsmnerr
Definition:
jsmn.h:46
Generated by
1.8.6