Added a header to simplify library usage

This commit is contained in:
Benoit Blanchon
2014-11-11 16:54:46 +01:00
parent e0ce711eb4
commit f6f8a63b99
25 changed files with 34 additions and 119 deletions

View File

@ -28,19 +28,6 @@ Assuming you installed the library into `<arduino-json>`, you need to add:
1. `<arduino-json>/include` to your include 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
View 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;

View File

@ -10,8 +10,4 @@
// for the IDE to find it. Feel free to ignore this file if your working in
// another environment
#include "../include/ArduinoJson/JsonArray.hpp"
#include "../include/ArduinoJson/JsonObject.hpp"
#include "../include/ArduinoJson/StaticJsonBuffer.hpp"
using namespace ArduinoJson;
#include "../include/ArduinoJson.h"

View File

@ -5,13 +5,9 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson.h>
#include "Printers.hpp"
using namespace ArduinoJson;
class GbathreeBug : public testing::Test {
public:
GbathreeBug() : object(buffer.parseObject(getJson())) {}

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class IntegrationTests : public testing::TestWithParam<const char*> {
static const size_t MAX_JSON_SIZE = 10000;

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
struct Person {
int id;

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonArray_Container_Tests : public ::testing::Test {
protected:

View File

@ -5,10 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
TEST(JsonArray_Iterator_Test, SimpleTest) {
StaticJsonBuffer<100> jsonBuffer;

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonArray_PrettyPrintTo_Tests : public testing::Test {
public:

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonArray_PrintTo_Tests : public testing::Test {
public:

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonObject_Container_Tests : public ::testing::Test {
public:

View File

@ -5,12 +5,9 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson.h>
#include "Printers.hpp"
using namespace ArduinoJson;
class JsonObject_Iterator_Test : public testing::Test {
public:
JsonObject_Iterator_Test() : object(_buffer.createObject()) {

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonObject_PrettyPrintTo_Tests : public testing::Test {
public:

View File

@ -5,11 +5,8 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson.h>
using namespace ArduinoJson;
using namespace ArduinoJson::Internals;
class JsonObject_PrintTo_Tests : public testing::Test {

View File

@ -5,10 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonParser_Array_Tests : public testing::Test {
protected:

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
TEST(JsonParser_Nested_Tests, ArrayNestedInObject) {
StaticJsonBuffer<256> jsonBuffer;

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonParser_NestingLimit_Tests : public testing::Test {
protected:

View File

@ -5,10 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson/JsonObject.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonParser_Object_Test : public testing::Test {
protected:

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonVariant_Copy_Tests : public ::testing::Test {
protected:

View File

@ -5,12 +5,9 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson.h>
#include "Printers.hpp"
using namespace ArduinoJson;
class JsonVariant_Invalid_Tests : public ::testing::Test {
public:
JsonVariant_Invalid_Tests() : variant(JsonVariant::invalid()) {}

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonVariant_Storage_Tests : public ::testing::Test {
protected:

View File

@ -5,11 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/StaticJsonBuffer.hpp>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
class JsonVariant_Subscript_Tests : public ::testing::Test {
protected:

View File

@ -5,12 +5,9 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson.h>
#include "Printers.hpp"
using namespace ArduinoJson;
class JsonVariant_Undefined_Tests : public ::testing::Test {
protected:
JsonVariant variant;

View File

@ -5,10 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonArray.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
TEST(StaticJsonBuffer_Array_Tests, GrowsWithArray) {
StaticJsonBuffer<JSON_ARRAY_SIZE(2)> json;

View File

@ -5,10 +5,7 @@
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#include <ArduinoJson/JsonObject.hpp>
#include <ArduinoJson/StaticJsonBuffer.hpp>
using namespace ArduinoJson;
#include <ArduinoJson.h>
TEST(StaticJsonBuffer_Object_Tests, GrowsWithObject) {
StaticJsonBuffer<JSON_OBJECT_SIZE(3)> json;