2014-07-16 13:26:11 +02:00
|
|
|
/*
|
|
|
|
* Arduino JSON library
|
|
|
|
* Benoit Blanchon 2014 - MIT License
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "jsmn.h"
|
2014-07-17 13:27:40 +02:00
|
|
|
|
|
|
|
#ifndef ARDUINO_JSON_NO_DEPRECATED_WARNING
|
2014-07-17 13:12:12 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define DEPRECATED __attribute__((deprecated))
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
#define DEPRECATED __declspec(deprecated)
|
2014-07-17 13:27:40 +02:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define DEPRECATED
|
2014-07-17 13:12:12 +02:00
|
|
|
#endif
|
2014-07-16 13:41:00 +02:00
|
|
|
|
2014-07-16 13:26:11 +02:00
|
|
|
namespace ArduinoJson
|
|
|
|
{
|
|
|
|
namespace Parser
|
|
|
|
{
|
|
|
|
class JsonArray;
|
|
|
|
class JsonHashTable;
|
|
|
|
|
2014-07-17 13:12:12 +02:00
|
|
|
class JsonValue
|
2014-07-16 13:26:11 +02:00
|
|
|
{
|
2014-07-17 13:58:30 +02:00
|
|
|
friend class JsonArrayIterator;
|
|
|
|
|
2014-07-16 13:26:11 +02:00
|
|
|
public:
|
2014-07-17 13:12:12 +02:00
|
|
|
JsonValue()
|
|
|
|
: json(0), tokens(0)
|
|
|
|
{
|
2014-07-16 13:41:00 +02:00
|
|
|
|
2014-07-17 13:12:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
JsonValue(char* json, jsmntok_t* tokens)
|
|
|
|
: json(json), tokens(tokens)
|
2014-07-16 13:26:11 +02:00
|
|
|
{
|
2014-07-16 13:41:00 +02:00
|
|
|
|
2014-07-17 13:12:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool success()
|
|
|
|
{
|
|
|
|
return json != 0 && tokens != 0;
|
2014-07-16 13:26:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
operator bool();
|
|
|
|
operator double();
|
|
|
|
operator long();
|
|
|
|
operator char*();
|
|
|
|
operator JsonArray();
|
|
|
|
operator JsonHashTable();
|
2014-07-17 12:59:26 +02:00
|
|
|
|
2014-07-17 13:12:12 +02:00
|
|
|
JsonValue operator[](const char*);
|
|
|
|
JsonValue operator[](int);
|
|
|
|
|
|
|
|
int size();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
char* json;
|
|
|
|
jsmntok_t* tokens;
|
|
|
|
|
|
|
|
static int getNestedTokenCount(jsmntok_t* token);
|
2014-07-16 13:26:11 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|