JSON object builder.
More...
#include <src/tooling/query/json.h>
JSON object builder.
Definition at line 189 of file json.h.
◆ JsonObject()
| ascii_query::json::JsonObject::JsonObject |
( |
| ) |
|
|
default |
◆ empty()
| bool ascii_query::json::JsonObject::empty |
( |
| ) |
const |
|
inline |
Definition at line 222 of file json.h.
222 {
223 return keys_.empty();
224 }
◆ set() [1/3]
| JsonObject & ascii_query::json::JsonObject::set |
( |
const std::string & |
key, |
|
|
const JsonArray & |
arr |
|
) |
| |
|
inline |
◆ set() [2/3]
◆ set() [3/3]
| JsonObject & ascii_query::json::JsonObject::set |
( |
const std::string & |
key, |
|
|
const JsonValue & |
value |
|
) |
| |
|
inline |
Definition at line 193 of file json.h.
193 {
194 keys_.push_back(key);
195 values_.push_back(value);
196 return *this;
197 }
◆ size()
| size_t ascii_query::json::JsonObject::size |
( |
| ) |
const |
|
inline |
Definition at line 225 of file json.h.
225 {
226 return keys_.size();
227 }
◆ toString()
| std::string ascii_query::json::JsonObject::toString |
( |
| ) |
const |
|
inline |
Definition at line 211 of file json.h.
211 {
212 std::string result = "{";
213 for (size_t i = 0; i < keys_.size(); i++) {
214 if (i > 0)
215 result += ",";
216 result +=
"\"" +
escape(keys_[i]) +
"\":" + values_[i].toString();
217 }
218 result += "}";
219 return result;
220 }
std::string escape(const std::string &str)
Escape a string for JSON output.
References ascii_query::json::escape().
Referenced by ascii_query::json::JsonArray::add(), and set().
The documentation for this class was generated from the following file: