FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ArduinoJsonParser/JsonArray.cpp at master · sutootoo/ArduinoJsonParser · GitHub
sutootoo
/
ArduinoJsonParser
Public
forked from
markert/ArduinoJsonParser
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ArduinoJsonParser
/
JsonArray.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (54 loc) · 1.36 KB
Breadcrumbs
ArduinoJsonParser
/
JsonArray.cpp
Copy path
File metadata and controls
67 lines (54 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* malloc-free JSON parser for Arduino
* Benoit Blanchon 2014 - MIT License
*/
#
include
"
JsonArray.h
"
#
include
"
JsonHashTable.h
"
JsonArray::JsonArray
(
char
* json,
jsmntok_t
* tokens)
: JsonObjectBase(json, tokens)
{
if
(tokens ==
0
|| tokens[
0
].
type
!=
JSMN_ARRAY
)
makeInvalid
();
}
/*
* Returns the token for the value at the specified index
*/
jsmntok_t
*
JsonArray::getToken
(
int
index)
{
//
sanity check
if
(json ==
0
|| tokens ==
0
|| index <
0
|| index >= tokens[
0
].
size
)
return
0
;
//
skip first token, it's the whole object
jsmntok_t
* currentToken = tokens +
1
;
//
skip all tokens before the specified index
for
(
int
i =
0
; i < index; i++)
{
//
move forward: current + nested tokens
currentToken +=
1
+
getNestedTokenCount
(currentToken);
}
return
currentToken;
}
JsonArray
JsonArray::getArray
(
int
index)
{
return
JsonArray
(json,
getToken
(index));
}
bool
JsonArray::getBool
(
int
index)
{
return
getBoolFromToken
(
getToken
(index));
}
double
JsonArray::getDouble
(
int
index)
{
return
getDoubleFromToken
(
getToken
(index));
}
JsonHashTable
JsonArray::getHashTable
(
int
index)
{
return
JsonHashTable
(json,
getToken
(index));
}
long
JsonArray::getLong
(
int
index)
{
return
getLongFromToken
(
getToken
(index));
}
char
*
JsonArray::getString
(
int
index)
{
return
getStringFromToken
(
getToken
(index));
}
Back
|
FazBrowse Home
|
New Git URL