连接器客户端
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace connector {
|
||||
|
||||
class Json {
|
||||
public:
|
||||
using Array = std::vector<Json>;
|
||||
using Object = std::map<std::string, Json>;
|
||||
|
||||
Json();
|
||||
Json(std::nullptr_t);
|
||||
Json(bool value);
|
||||
Json(double value);
|
||||
Json(const char* value);
|
||||
Json(std::string value);
|
||||
Json(Array value);
|
||||
Json(Object value);
|
||||
|
||||
static Json parse(const std::string& text);
|
||||
std::string dump(int indent = -1) const;
|
||||
|
||||
bool is_null() const;
|
||||
bool is_bool() const;
|
||||
bool is_number() const;
|
||||
bool is_string() const;
|
||||
bool is_array() const;
|
||||
bool is_object() const;
|
||||
|
||||
bool boolean(bool fallback = false) const;
|
||||
double number(double fallback = 0) const;
|
||||
const std::string& string() const;
|
||||
const Array& array() const;
|
||||
Array& array();
|
||||
const Object& object() const;
|
||||
Object& object();
|
||||
|
||||
const Json* find(const std::string& key) const;
|
||||
Json* find(const std::string& key);
|
||||
Json& operator[](const std::string& key);
|
||||
|
||||
private:
|
||||
using Value = std::variant<std::nullptr_t, bool, double, std::string, Array, Object>;
|
||||
Value value_;
|
||||
};
|
||||
|
||||
} // namespace connector
|
||||
Reference in New Issue
Block a user