Skip to content

Commit 3f38805

Browse files
Fixed major bug in 'JsonParser::readString'
Method was parsing chars as if they were numbers (i.e 'a' -> "97")
1 parent 589af3b commit 3f38805

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/JsonParserImpl.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace JStream {
1717

1818
bool JsonParser::readString(String& buf, bool inStr) {
1919
if(!inStr) {
20-
char c = skipWhitespace();
20+
int c = skipWhitespace();
2121
if(c != '"') return false;
2222
stream->read(); // Read opening '"'
2323
}
@@ -29,7 +29,7 @@ namespace JStream {
2929
if(c == 0) break;
3030
} else if (c == '"') return true;
3131

32-
buf += c;
32+
buf += (char)c;
3333
c = stream->read();
3434
}
3535

@@ -74,7 +74,7 @@ namespace JStream {
7474
long result = 0;
7575
long sign = 1;
7676

77-
char c = skipWhitespace();
77+
int c = skipWhitespace();
7878
if(c == '-') {
7979
stream->read();
8080
c = stream->peek();
@@ -104,7 +104,7 @@ namespace JStream {
104104
Internals::NumAccumulator acc;
105105

106106
// Determine number sign
107-
char c = skipWhitespace();
107+
int c = skipWhitespace();
108108
if(c == '-') {
109109
stream->read();
110110
c = stream->peek();
@@ -154,7 +154,7 @@ namespace JStream {
154154

155155
bool result;
156156
char* compareTo;
157-
char c = skipWhitespace();
157+
int c = skipWhitespace();
158158
if(c == 't') {
159159
result = true;
160160
compareTo = (char*)str_true + 1;
@@ -179,7 +179,7 @@ namespace JStream {
179179
template<typename T>
180180
bool JsonParser::parseIntArray(std::vector<T>& vec, bool inArray) {
181181
if(!inArray) {
182-
char c = skipWhitespace();
182+
int c = skipWhitespace();
183183

184184
if(c != '[') return false;
185185
stream->read();
@@ -189,7 +189,7 @@ namespace JStream {
189189
T sign = 1;
190190

191191
bool moreThanOneDigits = false;
192-
char c;
192+
int c;
193193
do {
194194
c = stream->read();
195195
switch(c) {
@@ -224,14 +224,14 @@ namespace JStream {
224224

225225
bool JsonParser::parseNumArray(std::vector<double>& vec, bool inArray) {
226226
if(!inArray) {
227-
char c = skipWhitespace();
227+
int c = skipWhitespace();
228228

229229
if(c != '[') return false;
230230
stream->read();
231231
}
232232

233233
Internals::NumAccumulator acc;
234-
char c;
234+
int c;
235235
do {
236236
c = stream->read();
237237
switch(c) {

src/JsonParserNav.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace JStream {
2121
if(!readString(*buf, true)) continue;
2222
}
2323

24-
char c = skipWhitespace();
24+
int c = skipWhitespace();
2525

2626
if(c != ':') {
2727
if(buf != nullptr) *buf = "";
@@ -163,14 +163,14 @@ namespace JStream {
163163
}
164164

165165
bool JsonParser::enterArr() {
166-
char c = skipWhitespace();
166+
int c = skipWhitespace();
167167
if(c != '[') return false;
168168
stream->read();
169169
return true;
170170
}
171171

172172
bool JsonParser::enterObj() {
173-
char c = skipWhitespace();
173+
int c = skipWhitespace();
174174
if(c != '{') return false;
175175
stream->read();
176176
return true;
@@ -211,7 +211,7 @@ namespace JStream {
211211

212212
bool JsonParser::skipString(bool inStr) {
213213
if(!inStr) {
214-
char c = skipWhitespace();
214+
int c = skipWhitespace();
215215
if(c != '"') return false;
216216
stream->read(); // Read opening '"'
217217
}
@@ -274,7 +274,7 @@ namespace JStream {
274274
}
275275

276276
char JsonParser::skipWhitespace() {
277-
char c;
277+
int c;
278278
do {
279279
c = stream->peek();
280280
if(Internals::isNotWhitespace(c)) break;

0 commit comments

Comments
 (0)