Pigweed
 
Loading...
Searching...
No Matches
builder.h File Reference
#include <cstddef>
#include <string_view>
#include <type_traits>
#include "pw_assert/assert.h"
#include "pw_json/internal/nesting.h"
#include "pw_span/span.h"
#include "pw_status/status.h"
#include "pw_status/status_with_size.h"
#include "pw_string/type_to_string.h"

Go to the source code of this file.

Classes

class  pw::NestedJsonArray
 
class  pw::NestedJsonObject
 
class  pw::JsonValue
 
class  pw::JsonArray
 
class  pw::JsonObject
 
class  pw::JsonBuilder
 
class  pw::JsonBuffer< kMaxSize >
 
struct  pw::json_impl::InvalidJsonType< T >
 
struct  pw::json_impl::LiteralChars
 

Namespaces

namespace  pw
 Provides basic helpers for reading and writing UTF-8 encoded strings.
 

Macros

#define PW_JSON_COMMON_INTERFACE_IMPL(name)
 

Functions

constexpr StatusWithSize pw::json_impl::WriteString (std::string_view value, char *buffer, size_t remaining)
 
constexpr char pw::json_impl::NibbleToHex (uint8_t nibble)
 
constexpr int pw::json_impl::EscapedStringCopy (char *destination, int copy_limit, std::string_view source)
 
constexpr StatusWithSize pw::json_impl::WriteQuotedString (std::string_view value, char *buffer, size_t buffer_size)
 
constexpr StatusWithSize pw::json_impl::WriteCharPointer (const char *ptr, char *buffer, size_t buffer_size)
 
template<typename T >
constexpr StatusWithSize pw::json_impl::SerializeJson (const T &value, char *buffer, size_t remaining)
 

Variables

constexpr char pw::json_impl::kArray [2] = {'[', ']'}
 
constexpr char pw::json_impl::kObject [2] = {'{', '}'}
 
template<typename T >
constexpr bool pw::json_impl::kIsJson
 

Detailed Description

The pw_json module provides utilities for interacting with JSON. JSON is a structured data format that supports strings, integers, floating point numbers, booleans, null, arrays, and objects (key-value pairs).

pw::JsonBuilder is a simple, efficient utility for serializing JSON to a fixed-sized buffer. It works directly with the JSON wire format. It does not support manipulation of previously serialized data.

All JsonBuilder functions are constexpr, so may be used in constexpr and constinit statements.

Variable Documentation

◆ kIsJson

template<typename T >
constexpr bool pw::json_impl::kIsJson
inlineconstexpr
Initial value:
=
std::is_base_of_v<JsonValue, T> || std::is_base_of_v<JsonArray, T> ||
std::is_base_of_v<JsonObject, T>