ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::json::JsonBuilder Class Reference

Builder class for creating JSON documents without lambdas. More...

#include <json_util.h>

Public Member Functions

 JsonBuilder ()
 
 JsonBuilder (ArduinoJson::Allocator *allocator)
 
JsonObject root ()
 
size_t serialize_to (char *buf, size_t cap)
 Serialize into a caller owned buffer.
 
SerializationBuffer serialize ()
 Serialize the JSON document to a SerializationBuffer (stack-first allocation) Uses 512-byte stack buffer by default, falls back to heap for larger JSON.
 

Detailed Description

Builder class for creating JSON documents without lambdas.

Definition at line 256 of file json_util.h.

Constructor & Destructor Documentation

◆ JsonBuilder() [1/2]

esphome::json::JsonBuilder::JsonBuilder ( )

Definition at line 67 of file json_util.cpp.

◆ JsonBuilder() [2/2]

esphome::json::JsonBuilder::JsonBuilder ( ArduinoJson::Allocator * allocator)
explicit

Definition at line 69 of file json_util.cpp.

Member Function Documentation

◆ root()

JsonObject esphome::json::JsonBuilder::root ( )
inline

Definition at line 265 of file json_util.h.

◆ serialize()

SerializationBuffer esphome::json::JsonBuilder::serialize ( )

Serialize the JSON document to a SerializationBuffer (stack-first allocation) Uses 512-byte stack buffer by default, falls back to heap for larger JSON.

Definition at line 96 of file json_util.cpp.

◆ serialize_to()

size_t esphome::json::JsonBuilder::serialize_to ( char * buf,
size_t cap )

Serialize into a caller owned buffer.

Returns the length; cap or more means it did not fit and buf holds a truncated, unterminated copy. An overflowed document serializes as "{}".

Definition at line 80 of file json_util.cpp.


The documentation for this class was generated from the following files: