Files
ArduinoJson/srcs/JsonValue.cpp

59 lines
1.1 KiB
C++
Raw Normal View History

2014-10-16 00:11:23 +02:00
#include "ArduinoJson/JsonValue.h"
2014-10-16 00:11:23 +02:00
#include "ArduinoJson/JsonArray.h"
#include "ArduinoJson/JsonObject.h"
#include "ArduinoJson/Internals/JsonNode.h"
void JsonValue::operator=(bool value)
{
2014-10-09 12:14:10 +02:00
if (_node)
_node->setAsBoolean(value);
}
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-10-09 12:14:10 +02:00
if (_node)
_node->setAsDouble(value, decimals);
}
void JsonValue::operator=(int value)
{
2014-10-09 12:14:10 +02:00
if (_node)
_node->setAsLong(value);
}
2014-09-27 15:25:00 +02:00
JsonValue::operator bool() const
{
2014-10-09 12:14:10 +02:00
return _node ? _node->getAsBoolean() : false;
}
2014-09-27 15:25:00 +02:00
JsonValue::operator char const*() const
{
2014-10-09 12:14:10 +02:00
return _node ? _node->getAsString() : 0;
}
2014-09-27 15:25:00 +02:00
JsonValue::operator double() const
{
2014-10-09 12:14:10 +02:00
return _node ? _node->getAsDouble() : 0;
}
2014-10-09 12:14:10 +02:00
JsonValue::operator long() const
{
2014-10-09 12:14:10 +02:00
return _node ? _node->getAsInteger() : 0;
}
JsonValue::operator JsonArray() const
{
2014-10-09 12:14:10 +02:00
return JsonArray(_node);
}
JsonValue::operator JsonObject() const
{
2014-10-09 12:14:10 +02:00
return JsonObject(_node);
}