forked from bblanchon/ArduinoJson
Parse simple strings
This commit is contained in:
@ -70,6 +70,11 @@ bool JsonParser::isSpace()
|
||||
return *_ptr == ' ' || *_ptr == '\t' || *_ptr == '\n' || *_ptr == '\r';
|
||||
}
|
||||
|
||||
bool JsonParser::isString()
|
||||
{
|
||||
return *_ptr == '\"';
|
||||
}
|
||||
|
||||
void JsonParser::skipOneChar()
|
||||
{
|
||||
_ptr++;
|
||||
@ -99,6 +104,9 @@ JsonNode* JsonParser::parseAnything()
|
||||
if (isNull())
|
||||
return parseNull();
|
||||
|
||||
if (isString())
|
||||
return parseString();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -168,3 +176,15 @@ JsonNode* JsonParser::parseNull()
|
||||
|
||||
return _buffer->createStringNode(0);
|
||||
}
|
||||
|
||||
JsonNode* JsonParser::parseString()
|
||||
{
|
||||
const char* s = ++_ptr;
|
||||
|
||||
while (*_ptr != '\"')
|
||||
_ptr++;
|
||||
*_ptr = 0;
|
||||
_ptr++;
|
||||
|
||||
return _buffer->createStringNode(s);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ private:
|
||||
inline bool isLong();
|
||||
inline bool isNull();
|
||||
inline bool isSpace();
|
||||
inline bool isString();
|
||||
|
||||
inline void skipOneChar();
|
||||
inline void skipSpaces();
|
||||
@ -37,6 +38,7 @@ private:
|
||||
inline JsonNode* parseBoolean();
|
||||
inline JsonNode* parseLong();
|
||||
inline JsonNode* parseNull();
|
||||
inline JsonNode* parseString();
|
||||
|
||||
JsonNode *parseDouble();
|
||||
};
|
Reference in New Issue
Block a user