forked from bblanchon/ArduinoJson
Extracted class JsonValue
This commit is contained in:
32
JsonGeneratorTests/JsonValue.cpp
Normal file
32
JsonGeneratorTests/JsonValue.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Arduino JSON library
|
||||
* Benoit Blanchon 2014 - MIT License
|
||||
*/
|
||||
|
||||
#include "JsonValue.h"
|
||||
#include "JsonObjectBase.h"
|
||||
|
||||
void JsonValue::writeTo(StringBuilder& sb)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case JSON_STRING:
|
||||
sb.appendEscaped(content.string);
|
||||
break;
|
||||
|
||||
case JSON_NUMBER:
|
||||
sb.append(content.number);
|
||||
break;
|
||||
|
||||
case JSON_BOOLEAN:
|
||||
sb.append(content.boolean ? "true" : "false");
|
||||
break;
|
||||
|
||||
case JSON_OBJECT:
|
||||
if (content.object)
|
||||
((JsonObjectBase*)content.object)->writeTo(sb);
|
||||
else
|
||||
sb.append("null");
|
||||
break;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user