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

#include <builder.h>

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

Public Member Functions

constexpr JsonValue (const JsonValue &)=delete
 
constexpr JsonValueoperator= (const JsonValue &)=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 Status Set (const T &value)
 

Friends

class JsonBuilder
 

Detailed Description

Stores a simple JSON value: a string, integer, float, boolean, or null. Provides a Set() function as well as the common functions for accessing the serialized data (see documentation for JsonBuilder).

Member Function Documentation

◆ Set()

template<typename T >
constexpr Status pw::JsonValue::Set ( const T &  value)
constexpr

Sets the JSON value to a boolean, number, string, or null. Sets and returns the status. If a Set call fails, the value is set to null.

It is an error to call Set() on a JsonValue if StartArray or StartObject was called on the JsonBuilder. Setting the JsonValue to a JSON object or array is also an error.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The value serialized successfully.
* 
*     RESOURCE_EXHAUSTED: There is insufficient buffer space to
*     serialize.
* 
*  

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