Pigweed
 
Loading...
Searching...
No Matches
pw::JsonObject Class Reference

#include <builder.h>

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

Public Member Functions

constexpr JsonObject (const JsonObject &)=delete
 
constexpr JsonObjectoperator= (const JsonObject &)=delete
 
constexpr bool IsValue () const
 
constexpr bool IsArray () const
 
constexpr bool IsObject () const
 
constexpr operator std::string_view () const
 
constexpr const char * data () const
 
constexpr size_t size () const
 
constexpr size_t max_size () const
 
constexpr bool ok () const
 
constexpr Status status () const
 
constexpr Status last_status () const
 
constexpr void clear ()
 
constexpr void clear_status ()
 
template<typename T >
constexpr JsonObjectAdd (std::string_view key, const T &value)
 
template<typename T >
constexpr JsonObjectAdd (std::nullptr_t, const T &value)=delete
 
constexpr NestedJsonArray AddNestedArray (std::string_view key)
 
constexpr NestedJsonObject AddNestedObject (std::string_view key)
 

Friends

class JsonBuilder
 

Detailed Description

Stores a JSON object: a sequence of key-value pairs. Provides functions for adding entries to the object, as well as the common functions for accessing the serialized data (see documentation for JsonBuilder).

Member Function Documentation

◆ Add()

template<typename T >
constexpr JsonObject & pw::JsonObject::Add ( std::string_view  key,
const T &  value 
)
constexpr

Adds a key-value pair to the JSON object. Updates the status.

It is an error to call Add() if the underlying JsonBuilder is no longer an object.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The value was appended successfully.
* 
*     RESOURCE_EXHAUSTED: Insufficient buffer space to serialize.
* 
*  

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