mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 06:33:51 +00:00
cleanup
This commit is contained in:
@@ -44,17 +44,6 @@ bool parse_json(const std::string &data, const json_parse_t &f) {
|
||||
// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
|
||||
}
|
||||
|
||||
// JsonBuilder implementation
|
||||
JsonBuilder::JsonBuilder()
|
||||
: doc_(
|
||||
#ifdef USE_PSRAM
|
||||
&allocator_
|
||||
#else
|
||||
nullptr
|
||||
#endif
|
||||
) {
|
||||
}
|
||||
|
||||
std::string JsonBuilder::serialize() {
|
||||
if (doc_.overflowed()) {
|
||||
ESP_LOGE(TAG, "JSON document overflow");
|
||||
|
||||
@@ -46,8 +46,6 @@ bool parse_json(const std::string &data, const json_parse_t &f);
|
||||
/// Builder class for creating JSON documents without lambdas
|
||||
class JsonBuilder {
|
||||
public:
|
||||
JsonBuilder();
|
||||
|
||||
JsonObject root() {
|
||||
if (!root_created_) {
|
||||
root_ = doc_.to<JsonObject>();
|
||||
@@ -60,9 +58,11 @@ class JsonBuilder {
|
||||
|
||||
private:
|
||||
#ifdef USE_PSRAM
|
||||
SpiRamAllocator allocator_; // Just a regular member on the stack!
|
||||
SpiRamAllocator allocator_; // Just a regular member on the stack!
|
||||
JsonDocument doc_{&allocator_}; // Initialize with allocator
|
||||
#else
|
||||
JsonDocument doc_; // Default initialization
|
||||
#endif
|
||||
JsonDocument doc_;
|
||||
JsonObject root_;
|
||||
bool root_created_{false};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user