75using number = json::number_integer_t;
104 using json = nlohmann::json;
115 :
data(std::move(j)) {}
117 jsonb(std::initializer_list<json::value_type> init)
126 operator const json &()
const {
144 operator[](
const std::string &key) {
148 operator[](
const std::string &key)
const {
153 operator[](
size_t i) {
157 operator[](
size_t i)
const {
190 dump(
int indent = -1)
const {
191 return data.dump(indent);
195 return data.is_null();
199 return data.is_object();
203 return data.is_array();
207 return data.is_string();
211 return data.is_number();
215 return data.is_boolean();
231 push_back(
const json &value) {
232 data.push_back(value);
235 erase(
const std::string &key) {
239 contains(
const std::string &key)
const {
240 return data.contains(key);
246 return a.data == b.data;
250 return a.data != b.data;
253 operator==(
const jsonb &a,
const json &b) {
257 operator==(
const json &a,
const jsonb &b) {
283using namespace nlohmann;
325 return os << j.dump();
346 return std::hash<std::string>{}(j.dump());
353#include <fmt/format.h>
362struct fmt::formatter<qb::
jsonb> : formatter<std::string> {
370 format(
const qb::jsonb &j, fmt::format_context &ctx) {
371 return formatter<std::string>::format(j.dump(), ctx);
Extensible buffer optimized for performance.
Definition pipe.h:552
json::number_float_t floating
JSON floating-point number type from nlohmann::json.
Definition json.h:83
std::ostream & operator<<(std::ostream &os, const qb::jsonb &j)
Stream output operator for qb::jsonb.
Definition json.h:324
json::boolean_t boolean
JSON boolean type from nlohmann::json.
Definition json.h:91
json object
Alias for the main JSON type from nlohmann::json.
Definition json.h:51
json::string_t string
JSON string type from nlohmann::json.
Definition json.h:67
json::array_t array
JSON array type from nlohmann::json.
Definition json.h:59
json::pointer pointer
JSON pointer type from nlohmann::json library.
Definition json.h:43
json::number_integer_t number
JSON integer number type from nlohmann::json.
Definition json.h:75
void from_json(qb::json const &obj, qb::uuid &id)
Converts a JSON object to a UUID.
void to_json(qb::json &obj, qb::uuid const &id)
Converts a UUID to a JSON object.
JSON protocol implementations for the QB IO system.
A wrapper around nlohmann::json providing a qb::jsonb type, often used for binary JSON (BSON) or simi...
Definition json.h:103
jsonb(const json &j)
Constructs from an existing nlohmann::json object (copy).
Definition json.h:111
const json & unwrap() const
Provides direct constant access to the underlying nlohmann::json object.
Definition json.h:275
jsonb(json &&j) noexcept
Constructs from an existing nlohmann::json object (move).
Definition json.h:114
jsonb()=default
Default constructor.
json data
The underlying nlohmann::json object storing the JSON data.
Definition json.h:105
json & operator=(const json &j)
Assigns from another nlohmann::json object (copy).
Definition json.h:133
jsonb(std::initializer_list< json::value_type > init)
Constructs from an initializer list, same as nlohmann::json.
Definition json.h:117
json & unwrap()
Provides direct mutable access to the underlying nlohmann::json object.
Definition json.h:267
std::size_t operator()(const qb::jsonb &j) const noexcept
Calculates the hash value for a qb::jsonb object.
Definition json.h:345
Universally Unique Identifier (UUID) support.
::uuids::uuid uuid
UUID type alias for the underlying implementation.
Definition uuid.h:40