C/C++ API Reference
Loading...
Searching...
No Matches
pw::JsonBuilder Class Reference

Overview

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.

Inheritance diagram for pw::JsonBuilder:
pw::JsonValue pw::JsonArray pw::JsonObject pw::JsonBuffer< kMaxSize >

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 JsonValueStartValue ()
 
constexpr JsonArrayStartArray ()
 
constexpr JsonObjectStartObject ()
 

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
 

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