JsonObjectImpl.hpp 761 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright Benoit Blanchon 2014-2017
  2. // MIT License
  3. //
  4. // Arduino JSON library
  5. // https://github.com/bblanchon/ArduinoJson
  6. // If you like this project, please add a star!
  7. #pragma once
  8. #include "JsonArray.hpp"
  9. #include "JsonObject.hpp"
  10. #include "JsonObjectSubscript.hpp"
  11. namespace ArduinoJson {
  12. template <typename TString>
  13. inline JsonObject &JsonObject::createNestedObject(const TString &key) {
  14. if (!_buffer) return JsonObject::invalid();
  15. JsonObject &object = _buffer->createObject();
  16. set(key, object);
  17. return object;
  18. }
  19. template <typename TString>
  20. inline JsonArray &JsonObject::createNestedArray(const TString &key) {
  21. if (!_buffer) return JsonArray::invalid();
  22. JsonArray &array = _buffer->createArray();
  23. set(key, array);
  24. return array;
  25. }
  26. }