2014-10-19 15:46:36 +02:00
|
|
|
#include "ArduinoJson/JsonValue.hpp"
|
2014-10-16 16:25:42 +02:00
|
|
|
|
2014-10-19 15:46:36 +02:00
|
|
|
#include "ArduinoJson/JsonArray.hpp"
|
|
|
|
#include "ArduinoJson/JsonObject.hpp"
|
|
|
|
#include "ArduinoJson/Internals/JsonNode.hpp"
|
2014-10-16 16:25:42 +02:00
|
|
|
|
2014-10-18 23:05:54 +02:00
|
|
|
using namespace ArduinoJson;
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
void JsonValue::operator=(bool value) {
|
|
|
|
if (_node)
|
|
|
|
_node->setAsBoolean(value);
|
2014-10-16 16:25:42 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
void JsonValue::operator=(char const *value) {
|
|
|
|
if (_node)
|
|
|
|
_node->setAsString(value);
|
2014-10-16 16:25:42 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
void JsonValue::set(double value, int decimals) {
|
|
|
|
if (_node)
|
|
|
|
_node->setAsDouble(value, decimals);
|
2014-10-16 16:25:42 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
void JsonValue::operator=(int value) {
|
|
|
|
if (_node)
|
|
|
|
_node->setAsLong(value);
|
2014-10-16 16:25:42 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
JsonValue::operator bool() const {
|
|
|
|
return _node ? _node->getAsBoolean() : false;
|
2014-10-16 16:25:42 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
JsonValue::operator char const *() const {
|
|
|
|
return _node ? _node->getAsString() : 0;
|
2014-10-16 16:25:42 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
JsonValue::operator double() const { return _node ? _node->getAsDouble() : 0; }
|
2014-10-16 16:25:42 +02:00
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
JsonValue::operator long() const { return _node ? _node->getAsInteger() : 0; }
|
2014-10-16 16:25:42 +02:00
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
JsonValue::operator JsonArray() const { return JsonArray(_node); }
|
2014-10-16 16:25:42 +02:00
|
|
|
|
2014-10-23 19:54:00 +02:00
|
|
|
JsonValue::operator JsonObject() const { return JsonObject(_node); }
|