AWS IoT Embedded C Device SDK
Main Page
Related Pages
Data Structures
Files
File List
Globals
external_libs
jsmn
jsmn.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Serge A. Zaitsev
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
31
#ifndef __JSMN_H_
32
#define __JSMN_H_
33
#include <stddef.h>
34
#define JSMN_STRICT
35
#ifdef __cplusplus
36
extern
"C"
{
37
#endif
38
46
typedef
enum
{
47
JSMN_PRIMITIVE = 0, JSMN_OBJECT = 1, JSMN_ARRAY = 2, JSMN_STRING = 3
48
}
jsmntype_t
;
49
50
typedef
enum
{
51
/* Not enough tokens were provided */
52
JSMN_ERROR_NOMEM = -1,
53
/* Invalid character inside JSON string */
54
JSMN_ERROR_INVAL = -2,
55
/* The string is not a full JSON packet, more bytes expected */
56
JSMN_ERROR_PART = -3,
57
} jsmnerr_t;
58
65
typedef
struct
{
66
jsmntype_t
type;
67
int
start;
68
int
end;
69
int
size;
70
#ifdef JSMN_PARENT_LINKS
71
int
parent;
72
#endif
73
}
jsmntok_t
;
74
79
typedef
struct
{
80
unsigned
int
pos;
/* offset in the JSON string */
81
unsigned
int
toknext;
/* next token to allocate */
82
int
toksuper;
/* superior token node, e.g parent object or array */
83
}
jsmn_parser
;
84
88
void
jsmn_init
(
jsmn_parser
*parser);
89
94
jsmnerr_t
jsmn_parse
(
jsmn_parser
*parser,
const
char
*js,
size_t
len,
95
jsmntok_t
*tokens,
unsigned
int
num_tokens);
96
97
#ifdef __cplusplus
98
}
99
#endif
100
101
#endif
/* __JSMN_H_ */
jsmntok_t
Definition:
jsmn.h:65
jsmntype_t
jsmntype_t
Definition:
jsmn.h:46
jsmn_parse
jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
Definition:
jsmn.c:193
jsmn_parser
Definition:
jsmn.h:79
jsmn_init
void jsmn_init(jsmn_parser *parser)
Definition:
jsmn.c:338
Generated by
1.8.10