Files
ArduinoJson/JsonParser/JsonValue.h

62 lines
1.2 KiB
C
Raw Normal View History

/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#pragma once
2014-07-18 15:43:20 +02:00
#include "JsonToken.h"
#ifndef ARDUINO_JSON_NO_DEPRECATED_WARNING
#ifdef __GNUC__
#define DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#endif
#else
#define DEPRECATED
#endif
namespace ArduinoJson
{
namespace Parser
{
class JsonArray;
2014-07-18 16:46:01 +02:00
class JsonObject;
class JsonValue
{
2014-07-18 15:43:20 +02:00
public:
2014-07-18 15:43:20 +02:00
JsonValue(char* json, Internal::JsonToken token)
: json(json), token(token)
{
}
bool success()
{
2014-07-18 15:43:20 +02:00
return token.isValid();
}
operator bool();
operator double();
operator long();
operator char*();
operator JsonArray();
2014-07-18 16:46:01 +02:00
operator JsonObject();
2014-07-18 15:43:20 +02:00
JsonValue operator[](int index);
JsonValue operator[](const char*key);
2014-07-18 15:43:20 +02:00
static JsonValue null()
{
return JsonValue(0, Internal::JsonToken(0));
}
private:
char* json;
2014-07-18 15:43:20 +02:00
Internal::JsonToken token;
};
}
}