Data Types
JsonElement
Stores the structure obtained after JSON deserialization and provides an interface for retrieving node values of basic data types by key.
class JsonElement : public Object {
shared<kacc_json::Document> doc{nullptr};
kacc_json::Node *node{nullptr};
};
GsonObject
Inherits from JsonElement and provides interfaces for obtaining child nodes of complex data types.
class GsonObject : public JsonElement {
public:
using JsonElement::JsonElement;
GsonObject *getAsJsonObject(const std::string &key);
JsonArray *getAsJsonArray(std::string_view key) const;
};
JsonArray
Inherits from JsonElement and provides the Array interface adapted to the Java basic library.
class JsonArray final : public JsonElement {
public:
class JsonArrayIterator final : public Iterator {
using jsonArrayIterator = std::list<JsonElement *>::iterator;
jsonArrayIterator current_;
jsonArrayIterator end_;
public:
JsonArrayIterator(const jsonArrayIterator begin, const jsonArrayIterator end);
bool hasNext() override;
Object *next() override;
};
void addLast(JsonElement *a);
std::list<JsonElement *> list;
Iterator *iterator();
~JsonArray() override;
};
JsonParser
Provides the deserialization interface.
class JsonParser final : public Object {
public:
static JsonElement *parseString(String *str);
};
Gson
Provides the toJson and fromJson interfaces.
class Gson : public Object {
public:
static String *toJson(JsonElement *jsonElement);
static String *toJson(Map *map);
static String *toJson(Object *obj);
static Object *fromJson(std::string str);
static Object *fromJson(String *str);
private:
static kacc_json::Node map2JsonNode(Map &map, Allocator &allo);
static kacc_json::Node list2JsonNode(List &list, Allocator &allo);
};
Parent topic: Function Syntax