2014-10-16 00:11:23 +02:00
|
|
|
#include "ArduinoJson/JsonValue.h"
|
2014-10-05 15:13:00 +02:00
|
|
|
|
2014-10-16 00:11:23 +02:00
|
|
|
#include "ArduinoJson/JsonArray.h"
|
|
|
|
#include "ArduinoJson/JsonObject.h"
|
|
|
|
#include "ArduinoJson/Internals/JsonNode.h"
|
2014-09-27 14:51:50 +02:00
|
|
|
|
2014-09-27 15:04:06 +02:00
|
|
|
void JsonValue::operator=(bool value)
|
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
if (_node)
|
|
|
|
_node->setAsBoolean(value);
|
2014-09-27 15:04:06 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 15:24:16 +02:00
|
|
|
void JsonValue::operator=(char const* value)
|
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
if (_node)
|
|
|
|
_node->setAsString(value);
|
2014-09-30 17:32:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void JsonValue::set(double value, int decimals)
|
2014-09-27 14:59:02 +02:00
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
if (_node)
|
|
|
|
_node->setAsDouble(value, decimals);
|
2014-09-27 14:59:02 +02:00
|
|
|
}
|
2014-09-27 14:51:50 +02:00
|
|
|
|
|
|
|
void JsonValue::operator=(int value)
|
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
if (_node)
|
|
|
|
_node->setAsLong(value);
|
2014-09-27 14:51:50 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 15:25:00 +02:00
|
|
|
JsonValue::operator bool() const
|
2014-09-27 15:04:06 +02:00
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
return _node ? _node->getAsBoolean() : false;
|
2014-09-27 15:04:06 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 15:25:00 +02:00
|
|
|
JsonValue::operator char const*() const
|
2014-09-27 15:24:16 +02:00
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
return _node ? _node->getAsString() : 0;
|
2014-09-27 15:24:16 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 15:25:00 +02:00
|
|
|
JsonValue::operator double() const
|
2014-09-27 14:59:02 +02:00
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
return _node ? _node->getAsDouble() : 0;
|
2014-09-27 14:59:02 +02:00
|
|
|
}
|
2014-09-27 14:51:50 +02:00
|
|
|
|
2014-10-09 12:14:10 +02:00
|
|
|
JsonValue::operator long() const
|
2014-09-27 14:51:50 +02:00
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
return _node ? _node->getAsInteger() : 0;
|
2014-09-27 16:18:40 +02:00
|
|
|
}
|
|
|
|
|
2014-10-05 15:13:00 +02:00
|
|
|
JsonValue::operator JsonArray() const
|
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
return JsonArray(_node);
|
2014-10-05 15:13:00 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 16:18:40 +02:00
|
|
|
JsonValue::operator JsonObject() const
|
|
|
|
{
|
2014-10-09 12:14:10 +02:00
|
|
|
return JsonObject(_node);
|
2014-09-27 14:51:50 +02:00
|
|
|
}
|