Skip to content

Commit

Permalink
Merge DynamicJsonDocument with JsonDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Mar 20, 2023
1 parent 6fb6a87 commit dd13f74
Show file tree
Hide file tree
Showing 164 changed files with 550 additions and 666 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -27,7 +27,7 @@ Here is the environment that I used:
Here is a small snippet that reproduces the issue.

```c++
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);

DeserializationError error = deserializeJson(doc, "{\"hello\":\"world\"}");

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/help.md
Expand Up @@ -28,7 +28,7 @@ Here is the environment that I'm using':
Here is a small snippet that demonstrate the problem.

```c++
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);

DeserializationError error = deserializeJson(doc, "{\"hello\":\"world\"}");

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -481,7 +481,7 @@ jobs:
g++ -x c++ - <<END
#include "${{ steps.amalgamate.outputs.filename }}"
int main() {
DynamicJsonDocument doc(300);
JsonDocument doc(300);
deserializeJson(doc, "{}");
}
END
Expand Down Expand Up @@ -515,7 +515,7 @@ jobs:
g++ -x c++ - <<END
#include "${{ steps.amalgamate.outputs.filename }}"
int main() {
ArduinoJson::DynamicJsonDocument doc(300);
ArduinoJson::JsonDocument doc(300);
deserializeJson(doc, "{}");
}
END
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,3 +7,4 @@ HEAD
* Remove `BasicJsonDocument`
* Remove `StaticJsonDocument`
* Add abstract `Allocator` class
* Merge `DynamicJsonDocument` with `JsonDocument`
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -110,7 +110,7 @@ Here is a program that parses a JSON document with ArduinoJson.
```c++
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";

DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
deserializeJson(doc, json);

const char* sensor = doc["sensor"];
Expand All @@ -126,7 +126,7 @@ See the [tutorial on arduinojson.org](https://arduinojson.org/v6/doc/deserializa
Here is a program that generates a JSON document with ArduinoJson:
```c++
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
doc["sensor"] = "gps";
doc["time"] = 1351824120;
Expand Down
4 changes: 2 additions & 2 deletions examples/JsonConfigFile/JsonConfigFile.ino
Expand Up @@ -45,7 +45,7 @@ void loadConfiguration(const char* filename, Config& config) {
// Allocate a temporary JsonDocument
// Don't forget to change the capacity to match your requirements.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(512);
JsonDocument doc(512);

// Deserialize the JSON document
DeserializationError error = deserializeJson(doc, file);
Expand Down Expand Up @@ -77,7 +77,7 @@ void saveConfiguration(const char* filename, const Config& config) {
// Allocate a temporary JsonDocument
// Don't forget to change the capacity to match your requirements.
// Use https://arduinojson.org/assistant to compute the capacity.
DynamicJsonDocument doc(256);
JsonDocument doc(256);

// Set the values in the document
doc["hostname"] = config.hostname;
Expand Down
4 changes: 2 additions & 2 deletions examples/JsonFilterExample/JsonFilterExample.ino
Expand Up @@ -34,12 +34,12 @@ void setup() {
"1000000,\"timezone\":0,\"sunrise\":1581492085,\"sunset\":1581527294}}");

// The filter: it contains "true" for each value we want to keep
DynamicJsonDocument filter(200);
JsonDocument filter(200);
filter["list"][0]["dt"] = true;
filter["list"][0]["main"]["temp"] = true;

// Deserialize the document
DynamicJsonDocument doc(400);
JsonDocument doc(400);
deserializeJson(doc, input_json, DeserializationOption::Filter(filter));

// Print the result
Expand Down
2 changes: 1 addition & 1 deletion examples/JsonGeneratorExample/JsonGeneratorExample.ino
Expand Up @@ -19,7 +19,7 @@ void setup() {
// Inside the parentheses, 200 is the RAM allocated to this document.
// Don't forget to change this value to match your requirement.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(200);
JsonDocument doc(200);

// Add values in the document
//
Expand Down
2 changes: 1 addition & 1 deletion examples/JsonHttpClient/JsonHttpClient.ino
Expand Up @@ -79,7 +79,7 @@ void setup() {
// Allocate the JSON document
// Use https://arduinojson.org/v6/assistant to compute the capacity.
const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;
DynamicJsonDocument doc(capacity);
JsonDocument doc(capacity);

// Parse JSON object
DeserializationError error = deserializeJson(doc, client);
Expand Down
2 changes: 1 addition & 1 deletion examples/JsonParserExample/JsonParserExample.ino
Expand Up @@ -19,7 +19,7 @@ void setup() {
// Inside the parentheses, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(200);
JsonDocument doc(200);

// JSON input string.
//
Expand Down
2 changes: 1 addition & 1 deletion examples/JsonServer/JsonServer.ino
Expand Up @@ -58,7 +58,7 @@ void loop() {

// Allocate a temporary JsonDocument
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(500);
JsonDocument doc(500);

// Create the "analog" array
JsonArray analogValues = doc.createNestedArray("analog");
Expand Down
2 changes: 1 addition & 1 deletion examples/JsonUdpBeacon/JsonUdpBeacon.ino
Expand Up @@ -48,7 +48,7 @@ void setup() {
void loop() {
// Allocate a temporary JsonDocument
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(500);
JsonDocument doc(500);

// Create the "analog" array
JsonArray analogValues = doc.createNestedArray("analog");
Expand Down
2 changes: 1 addition & 1 deletion examples/MsgPackParser/MsgPackParser.ino
Expand Up @@ -20,7 +20,7 @@ void setup() {
// Inside the parentheses, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(200);
JsonDocument doc(200);

// MessagePack input string.
//
Expand Down
2 changes: 1 addition & 1 deletion examples/ProgmemExample/ProgmemExample.ino
Expand Up @@ -14,7 +14,7 @@
#include <ArduinoJson.h>

void setup() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);

// You can use a Flash String as your JSON input.
// WARNING: the strings in the input will be duplicated in the JsonDocument.
Expand Down
2 changes: 1 addition & 1 deletion examples/StringExample/StringExample.ino
Expand Up @@ -13,7 +13,7 @@
#include <ArduinoJson.h>

void setup() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);

// You can use a String as your JSON input.
// WARNING: the string in the input will be duplicated in the JsonDocument.
Expand Down
2 changes: 1 addition & 1 deletion extras/ci/espidf/main/main.cpp
Expand Up @@ -6,7 +6,7 @@

extern "C" void app_main() {
char buffer[256];
DynamicJsonDocument doc(200);
JsonDocument doc(200);

doc["hello"] = "world";
serializeJson(doc, buffer);
Expand Down
2 changes: 1 addition & 1 deletion extras/fuzzing/json_fuzzer.cpp
@@ -1,7 +1,7 @@
#include <ArduinoJson.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
DynamicJsonDocument doc(4096);
JsonDocument doc(4096);
DeserializationError error = deserializeJson(doc, data, size);
if (!error) {
std::string json;
Expand Down
2 changes: 1 addition & 1 deletion extras/fuzzing/msgpack_fuzzer.cpp
@@ -1,7 +1,7 @@
#include <ArduinoJson.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
DynamicJsonDocument doc(4096);
JsonDocument doc(4096);
DeserializationError error = deserializeMsgPack(doc, data, size);
if (!error) {
std::string json;
Expand Down
2 changes: 1 addition & 1 deletion extras/scripts/wandbox/JsonGeneratorExample.cpp
Expand Up @@ -13,7 +13,7 @@ int main() {
// Inside the parentheses, 200 is the RAM allocated to this document.
// Don't forget to change this value to match your requirement.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(200);
JsonDocument doc(200);

// Add values in the document
//
Expand Down
2 changes: 1 addition & 1 deletion extras/scripts/wandbox/JsonParserExample.cpp
Expand Up @@ -13,7 +13,7 @@ int main() {
// Inside the parentheses, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(300);
JsonDocument doc(300);

// JSON input string.
//
Expand Down
2 changes: 1 addition & 1 deletion extras/scripts/wandbox/MsgPackParserExample.cpp
Expand Up @@ -13,7 +13,7 @@ int main() {
// Inside the parentheses, 300 is the size of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use https://arduinojson.org/assistant to compute the capacity.
DynamicJsonDocument doc(300);
JsonDocument doc(300);

// MessagePack input string.
//
Expand Down
2 changes: 1 addition & 1 deletion extras/tests/Cpp17/string_view.cpp
Expand Up @@ -8,7 +8,7 @@
#endif

TEST_CASE("string_view") {
DynamicJsonDocument doc(256);
JsonDocument doc(256);
JsonVariant variant = doc.to<JsonVariant>();

SECTION("deserializeJson()") {
Expand Down
2 changes: 1 addition & 1 deletion extras/tests/Cpp20/smoke_test.cpp
Expand Up @@ -4,7 +4,7 @@
#include <string>

TEST_CASE("C++20 smoke test") {
DynamicJsonDocument doc(128);
JsonDocument doc(128);

deserializeJson(doc, "{\"hello\":\"world\"}");
REQUIRE(doc["hello"] == "world");
Expand Down
6 changes: 0 additions & 6 deletions extras/tests/FailingBuilds/CMakeLists.txt
Expand Up @@ -23,18 +23,12 @@ endmacro()
add_executable(Issue978 Issue978.cpp)
build_should_fail(Issue978)

add_executable(Issue1189 Issue1189.cpp)
build_should_fail(Issue1189)

add_executable(read_long_long read_long_long.cpp)
build_should_fail(read_long_long)

add_executable(write_long_long write_long_long.cpp)
build_should_fail(write_long_long)

add_executable(delete_jsondocument delete_jsondocument.cpp)
build_should_fail(delete_jsondocument)

add_executable(variant_as_char variant_as_char.cpp)
build_should_fail(variant_as_char)

Expand Down
13 changes: 0 additions & 13 deletions extras/tests/FailingBuilds/Issue1189.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion extras/tests/FailingBuilds/Issue978.cpp
Expand Up @@ -8,6 +8,6 @@ struct Stream {};

int main() {
Stream* stream = 0;
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
deserializeJson(doc, stream);
}
2 changes: 1 addition & 1 deletion extras/tests/FailingBuilds/assign_char.cpp
Expand Up @@ -7,6 +7,6 @@
// See issue #1498

int main() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
doc["dummy"] = 'A';
}
12 changes: 0 additions & 12 deletions extras/tests/FailingBuilds/delete_jsondocument.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion extras/tests/FailingBuilds/read_long_long.cpp
Expand Up @@ -11,6 +11,6 @@

ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(long long)
int main() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
doc["dummy"].as<long long>();
}
2 changes: 1 addition & 1 deletion extras/tests/FailingBuilds/variant_as_char.cpp
Expand Up @@ -7,6 +7,6 @@
// See issue #1498

int main() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
doc["dummy"].as<char>();
}
2 changes: 1 addition & 1 deletion extras/tests/FailingBuilds/write_long_long.cpp
Expand Up @@ -10,6 +10,6 @@
#endif

int main() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
doc["dummy"] = static_cast<long long>(42);
}
2 changes: 1 addition & 1 deletion extras/tests/IntegrationTests/gbathree.cpp
Expand Up @@ -6,7 +6,7 @@
#include <catch.hpp>

TEST_CASE("Gbathree") {
DynamicJsonDocument doc(4096);
JsonDocument doc(4096);

DeserializationError error = deserializeJson(
doc,
Expand Down
4 changes: 2 additions & 2 deletions extras/tests/IntegrationTests/issue772.cpp
Expand Up @@ -8,8 +8,8 @@
// https://github.com/bblanchon/ArduinoJson/issues/772

TEST_CASE("Issue772") {
DynamicJsonDocument doc1(4096);
DynamicJsonDocument doc2(4096);
JsonDocument doc1(4096);
JsonDocument doc2(4096);
DeserializationError err;
std::string data =
"{\"state\":{\"reported\":{\"timestamp\":\"2018-07-02T09:40:12Z\","
Expand Down
4 changes: 2 additions & 2 deletions extras/tests/IntegrationTests/openweathermap.cpp
Expand Up @@ -53,12 +53,12 @@ TEST_CASE("OpenWeatherMap") {
"]}";
// clang-format on

DynamicJsonDocument filter(512);
JsonDocument filter(512);
filter["list"][0]["dt"] = true;
filter["list"][0]["main"]["temp"] = true;
filter["list"][0]["weather"][0]["description"] = true;

DynamicJsonDocument doc(16384);
JsonDocument doc(16384);

REQUIRE(
deserializeJson(doc, input_json, DeserializationOption::Filter(filter)) ==
Expand Down
2 changes: 1 addition & 1 deletion extras/tests/IntegrationTests/round_trip.cpp
Expand Up @@ -6,7 +6,7 @@
#include <catch.hpp>

void check(std::string originalJson) {
DynamicJsonDocument doc(16384);
JsonDocument doc(16384);

std::string prettyJson;
deserializeJson(doc, originalJson);
Expand Down

0 comments on commit dd13f74

Please sign in to comment.