mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 04:52:22 +02:00
Replaced composition by inheritance
This commit is contained in:
@ -9,23 +9,22 @@
|
||||
#include "JsonValue.h"
|
||||
|
||||
using namespace ArduinoJson::Parser;
|
||||
using namespace ArduinoJson::Internal;
|
||||
|
||||
JsonValue JsonValue::operator[](int index)
|
||||
{
|
||||
return JsonArray(json, token)[index];
|
||||
return JsonArray(*this)[index];
|
||||
}
|
||||
|
||||
JsonValue JsonValue::operator[](const char* key)
|
||||
{
|
||||
return JsonObject(json, token)[key];
|
||||
return JsonObject(*this)[key];
|
||||
}
|
||||
|
||||
JsonValue::operator bool()
|
||||
{
|
||||
if (!token.isPrimitive()) return 0;
|
||||
if (!isPrimitive()) return 0;
|
||||
|
||||
char *text = token.getText(json);
|
||||
char *text = getText();
|
||||
|
||||
// "true"
|
||||
if (text[0] == 't') return true;
|
||||
@ -42,29 +41,25 @@ JsonValue::operator bool()
|
||||
|
||||
JsonValue::operator double()
|
||||
{
|
||||
return token.isPrimitive() ? strtod(token.getText(json), 0) : 0;
|
||||
return isPrimitive() ? strtod(getText(), 0) : 0;
|
||||
}
|
||||
|
||||
JsonValue::operator long()
|
||||
{
|
||||
return token.isPrimitive() ? strtol(token.getText(json), 0, 0) : 0;
|
||||
return isPrimitive() ? strtol(getText(), 0, 0) : 0;
|
||||
}
|
||||
|
||||
JsonValue::operator char*()
|
||||
{
|
||||
return token.isString() || token.isPrimitive() ? token.getText(json) : 0;
|
||||
return isString() || isPrimitive() ? getText() : 0;
|
||||
}
|
||||
|
||||
JsonValue::operator JsonArray()
|
||||
{
|
||||
return token.isArray()
|
||||
? JsonArray(json, token)
|
||||
: JsonArray::null();
|
||||
return *this;
|
||||
}
|
||||
|
||||
JsonValue::operator JsonObject()
|
||||
{
|
||||
return token.isObject()
|
||||
? JsonObject(json, token)
|
||||
: JsonObject::null();
|
||||
return *this;
|
||||
}
|
Reference in New Issue
Block a user