mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 11:36:36 +02:00
More test on object parsing
This commit is contained in:
@ -211,7 +211,12 @@ JsonNode* JsonParser::parseObject()
|
||||
|
||||
for(;;)
|
||||
{
|
||||
node->addChild(parseObjectKeyValue());
|
||||
JsonNode* keyValueNode = parseObjectKeyValue();
|
||||
|
||||
if (!keyValueNode)
|
||||
return 0;
|
||||
|
||||
node->addChild(keyValueNode);
|
||||
|
||||
skipSpaces();
|
||||
|
||||
@ -229,6 +234,9 @@ JsonNode* JsonParser::parseObjectKeyValue()
|
||||
{
|
||||
const char* key = QuotedString::extractFrom(_ptr, &_ptr);
|
||||
|
||||
if (!key)
|
||||
return 0;
|
||||
|
||||
skipSpaces();
|
||||
|
||||
if (!isColon())
|
||||
|
@ -10,7 +10,6 @@ void JsonWriter::writeString(char const* value)
|
||||
|
||||
void JsonWriter::writeInteger(long value)
|
||||
{
|
||||
|
||||
_length += _sink->print(value);
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,6 @@ char* QuotedString::extractFrom(char* input, char** endPtr)
|
||||
if (c == 0)
|
||||
{
|
||||
// premature ending
|
||||
*endPtr = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -54,6 +54,21 @@ TEST_F(JsonParser_Object_Test, MissingClosingBrace)
|
||||
sizeMustBe(0);
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_Object_Test, MissingColonAndValue)
|
||||
{
|
||||
whenInputIs("{\"key\"}");
|
||||
parseMustFail();
|
||||
sizeMustBe(0);
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_Object_Test, MissingQuotesAndColonAndValue)
|
||||
{
|
||||
whenInputIs("{key}");
|
||||
parseMustFail();
|
||||
sizeMustBe(0);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(JsonParser_Object_Test, OneStringNoSpace)
|
||||
{
|
||||
whenInputIs("{\"key\":\"value\"}");
|
||||
|
Reference in New Issue
Block a user