|
Pigweed
|
#include <builder.h>
Public Member Functions | |
| constexpr | JsonBuilder (span< char > buffer) |
Initializes to the value null. buffer.size() must be at least 5. | |
| constexpr | JsonBuilder (char *buffer, size_t buffer_size) |
Initializes to the value null. buffer_size must be at least 5. | |
| constexpr bool | IsValue () const |
| True if the top-level JSON entity is a simple value (not array or object). | |
| constexpr bool | IsArray () const |
| True if the top-level JSON entity is an array. | |
| constexpr bool | IsObject () const |
| True if the top-level JSON entity is an object. | |
| constexpr | operator std::string_view () const |
JsonBuilder converts to std::string_view. | |
| constexpr const char * | data () const |
| Pointer to the serialized JSON, which is always a null-terminated string. | |
| constexpr size_t | size () const |
| The current size of the JSON string, excluding the null terminator. | |
| constexpr size_t | max_size () const |
| The maximum size of the JSON string, excluding the null terminator. | |
| constexpr bool | ok () const |
| True if. | |
| constexpr Status | status () const |
| constexpr Status | last_status () const |
| constexpr void | clear () |
Sets the JSON null and clears the status. | |
| constexpr void | clear_status () |
Resets status() and last_status(). | |
| template<typename T > | |
| constexpr Status | SetValue (const T &value) |
Clears the JSON and sets it to a single JSON value (see JsonValue::Set). | |
| constexpr JsonValue & | StartValue () |
| constexpr JsonArray & | StartArray () |
| constexpr JsonObject & | StartObject () |
Static Public Member Functions | |
| static constexpr size_t | MinBufferSize () |
JsonBuilder requires at least 5 characters in its buffer. | |
Protected Types | |
| enum class | Uninitialized |
Protected Member Functions | |
| constexpr | JsonBuilder (char *buffer, size_t buffer_size, Uninitialized) |
| constexpr void | MakeNull () |
| constexpr void | set_json_size (size_t json_size) |
| constexpr void | set_statuses (Status status, Status last_status) |
Friends | |
| class | JsonValue |
| class | JsonArray |
| class | JsonObject |
| class | NestedJsonArray |
| class | NestedJsonObject |
JsonBuilder is used to create arbitrary JSON. Contains a JSON value, which may be an object or array. Arrays and objects may contain other values, objects, or arrays.
|
inlineconstexpr |
Returns the status from the most recent change to the JSON. This is set with each JSON update and may be
embed:rst:inline :c:enumerator:`OK`
while status() is not.
|
inlineconstexpr |
True if.
embed:rst:inline :cpp:func:`status`
is
embed:rst:inline :c:enumerator:`OK`
; no errors have occurred.
|
inlineconstexpr |
Clears the JSON and sets it to an empty array ([]). Returns a JsonArray reference to this JsonBuilder. For example:
|
inlineconstexpr |
Clears the JSON and sets it to an empty object ({}). Returns a JsonObject reference to this JsonBuilder. For example:
|
inlineconstexpr |
Sets the JSON to null and returns a JsonValue reference to this JsonBuilder.
|
inlineconstexpr |
Returns the JsonBuilder's status, which reflects the first error that occurred while updating the JSON. After an update fails, the non-OK status remains until it is reset with clear, clear_status, or SetValue.
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: All previous updates have succeeded. * * RESOURCE_EXHAUSTED: An update did not fit in the buffer. * *