forked from bblanchon/ArduinoJson
Added a header to simplify library usage
This commit is contained in:
@ -28,19 +28,6 @@ Assuming you installed the library into `<arduino-json>`, you need to add:
|
|||||||
1. `<arduino-json>/include` to your include path
|
1. `<arduino-json>/include` to your include path
|
||||||
2. `<arduino-json>/lib` to your library path
|
2. `<arduino-json>/lib` to your library path
|
||||||
|
|
||||||
## Headers
|
|
||||||
|
|
||||||
The following headers are required:
|
|
||||||
|
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
## Namespace
|
|
||||||
|
|
||||||
Every class of the library is declared in the `ArduinoJson` namespace, so you may want to add the following line after the `#include` statements:
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
11
include/ArduinoJson.h
Normal file
11
include/ArduinoJson.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright Benoit Blanchon 2014
|
||||||
|
// MIT License
|
||||||
|
//
|
||||||
|
// Arduino JSON library
|
||||||
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
|
#include "../include/ArduinoJson/JsonArray.hpp"
|
||||||
|
#include "../include/ArduinoJson/JsonObject.hpp"
|
||||||
|
#include "../include/ArduinoJson/StaticJsonBuffer.hpp"
|
||||||
|
|
||||||
|
using namespace ArduinoJson;
|
@ -10,8 +10,4 @@
|
|||||||
// for the IDE to find it. Feel free to ignore this file if your working in
|
// for the IDE to find it. Feel free to ignore this file if your working in
|
||||||
// another environment
|
// another environment
|
||||||
|
|
||||||
#include "../include/ArduinoJson/JsonArray.hpp"
|
#include "../include/ArduinoJson.h"
|
||||||
#include "../include/ArduinoJson/JsonObject.hpp"
|
|
||||||
#include "../include/ArduinoJson/StaticJsonBuffer.hpp"
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
@ -5,13 +5,9 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include "Printers.hpp"
|
#include "Printers.hpp"
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class GbathreeBug : public testing::Test {
|
class GbathreeBug : public testing::Test {
|
||||||
public:
|
public:
|
||||||
GbathreeBug() : object(buffer.parseObject(getJson())) {}
|
GbathreeBug() : object(buffer.parseObject(getJson())) {}
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class IntegrationTests : public testing::TestWithParam<const char*> {
|
class IntegrationTests : public testing::TestWithParam<const char*> {
|
||||||
static const size_t MAX_JSON_SIZE = 10000;
|
static const size_t MAX_JSON_SIZE = 10000;
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
struct Person {
|
struct Person {
|
||||||
int id;
|
int id;
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonArray_Container_Tests : public ::testing::Test {
|
class JsonArray_Container_Tests : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
TEST(JsonArray_Iterator_Test, SimpleTest) {
|
TEST(JsonArray_Iterator_Test, SimpleTest) {
|
||||||
StaticJsonBuffer<100> jsonBuffer;
|
StaticJsonBuffer<100> jsonBuffer;
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonArray_PrettyPrintTo_Tests : public testing::Test {
|
class JsonArray_PrettyPrintTo_Tests : public testing::Test {
|
||||||
public:
|
public:
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonArray_PrintTo_Tests : public testing::Test {
|
class JsonArray_PrintTo_Tests : public testing::Test {
|
||||||
public:
|
public:
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonObject_Container_Tests : public ::testing::Test {
|
class JsonObject_Container_Tests : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
@ -5,12 +5,9 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
#include "Printers.hpp"
|
#include "Printers.hpp"
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonObject_Iterator_Test : public testing::Test {
|
class JsonObject_Iterator_Test : public testing::Test {
|
||||||
public:
|
public:
|
||||||
JsonObject_Iterator_Test() : object(_buffer.createObject()) {
|
JsonObject_Iterator_Test() : object(_buffer.createObject()) {
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonObject_PrettyPrintTo_Tests : public testing::Test {
|
class JsonObject_PrettyPrintTo_Tests : public testing::Test {
|
||||||
public:
|
public:
|
||||||
|
@ -5,11 +5,8 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
class JsonObject_PrintTo_Tests : public testing::Test {
|
class JsonObject_PrintTo_Tests : public testing::Test {
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonParser_Array_Tests : public testing::Test {
|
class JsonParser_Array_Tests : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
TEST(JsonParser_Nested_Tests, ArrayNestedInObject) {
|
TEST(JsonParser_Nested_Tests, ArrayNestedInObject) {
|
||||||
StaticJsonBuffer<256> jsonBuffer;
|
StaticJsonBuffer<256> jsonBuffer;
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonParser_NestingLimit_Tests : public testing::Test {
|
class JsonParser_NestingLimit_Tests : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonParser_Object_Test : public testing::Test {
|
class JsonParser_Object_Test : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonVariant_Copy_Tests : public ::testing::Test {
|
class JsonVariant_Copy_Tests : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,12 +5,9 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include "Printers.hpp"
|
#include "Printers.hpp"
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonVariant_Invalid_Tests : public ::testing::Test {
|
class JsonVariant_Invalid_Tests : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
JsonVariant_Invalid_Tests() : variant(JsonVariant::invalid()) {}
|
JsonVariant_Invalid_Tests() : variant(JsonVariant::invalid()) {}
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonVariant_Storage_Tests : public ::testing::Test {
|
class JsonVariant_Storage_Tests : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonVariant_Subscript_Tests : public ::testing::Test {
|
class JsonVariant_Subscript_Tests : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,12 +5,9 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
|
||||||
#include "Printers.hpp"
|
#include "Printers.hpp"
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
class JsonVariant_Undefined_Tests : public ::testing::Test {
|
class JsonVariant_Undefined_Tests : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
JsonVariant variant;
|
JsonVariant variant;
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonArray.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
TEST(StaticJsonBuffer_Array_Tests, GrowsWithArray) {
|
TEST(StaticJsonBuffer_Array_Tests, GrowsWithArray) {
|
||||||
StaticJsonBuffer<JSON_ARRAY_SIZE(2)> json;
|
StaticJsonBuffer<JSON_ARRAY_SIZE(2)> json;
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ArduinoJson/JsonObject.hpp>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoJson/StaticJsonBuffer.hpp>
|
|
||||||
|
|
||||||
using namespace ArduinoJson;
|
|
||||||
|
|
||||||
TEST(StaticJsonBuffer_Object_Tests, GrowsWithObject) {
|
TEST(StaticJsonBuffer_Object_Tests, GrowsWithObject) {
|
||||||
StaticJsonBuffer<JSON_OBJECT_SIZE(3)> json;
|
StaticJsonBuffer<JSON_OBJECT_SIZE(3)> json;
|
||||||
|
Reference in New Issue
Block a user