ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
ascii_query::json::JsonArray Class Reference

JSON array builder. More...

#include <src/tooling/query/json.h>

Public Member Functions

 JsonArray ()=default
 
JsonArrayadd (const JsonValue &value)
 
JsonArrayadd (const JsonArray &arr)
 
JsonArrayadd (const JsonObject &obj)
 
std::string toString () const
 
bool empty () const
 
size_t size () const
 

Detailed Description

JSON array builder.

Definition at line 146 of file json.h.

Constructor & Destructor Documentation

◆ JsonArray()

ascii_query::json::JsonArray::JsonArray ( )
default

Member Function Documentation

◆ add() [1/3]

JsonArray & ascii_query::json::JsonArray::add ( const JsonArray arr)
inline

Definition at line 155 of file json.h.

155 {
156 values_.push_back(JsonValue::fromArray(arr.toString()));
157 return *this;
158 }
static JsonValue fromArray(const std::string &serialized)
Definition json.h:96

References ascii_query::json::JsonValue::fromArray(), and toString().

◆ add() [2/3]

JsonArray & ascii_query::json::JsonArray::add ( const JsonObject obj)
inline

Definition at line 235 of file json.h.

235 {
236 values_.push_back(JsonValue::fromObject(obj.toString()));
237 return *this;
238}
static JsonValue fromObject(const std::string &serialized)
Definition json.h:103

References ascii_query::json::JsonValue::fromObject(), and ascii_query::json::JsonObject::toString().

◆ add() [3/3]

JsonArray & ascii_query::json::JsonArray::add ( const JsonValue value)
inline

Definition at line 150 of file json.h.

150 {
151 values_.push_back(value);
152 return *this;
153 }

◆ empty()

bool ascii_query::json::JsonArray::empty ( ) const
inline

Definition at line 175 of file json.h.

175 {
176 return values_.empty();
177 }

◆ size()

size_t ascii_query::json::JsonArray::size ( ) const
inline

Definition at line 178 of file json.h.

178 {
179 return values_.size();
180 }

◆ toString()

std::string ascii_query::json::JsonArray::toString ( ) const
inline

Definition at line 162 of file json.h.

162 {
163 std::string result = "[";
164 bool first = true;
165 for (const auto &v : values_) {
166 if (!first)
167 result += ",";
168 first = false;
169 result += v.toString();
170 }
171 result += "]";
172 return result;
173 }

Referenced by add(), and ascii_query::json::JsonObject::set().


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