Lines Matching defs:root
55 // get root node
57 cJSON *root = cJSON_Parse(content.c_str());
58 if (root == nullptr || cJSON_IsInvalid(root)) {
59 cJSON_Delete(root);
64 Init(root, true);
67 JsonNode::JsonNode(const cJSON *root, bool needDelete)
69 if (root != nullptr && !cJSON_IsInvalid(root)) {
70 Init(root, needDelete);
73 LOG(ERROR) << "root is not valid";
78 void JsonNode::Init(const cJSON *root, bool needDelete)
80 if (auto it = GetJsonTypeMap().find(root->type); it != GetJsonTypeMap().end()) {
83 Parse(root);
85 cJSON_Delete(const_cast<cJSON *>(root));
89 void JsonNode::Parse(const cJSON *root)
97 cJSON_ArrayForEach(element, root)
109 cJSON_ArrayForEach(element, root)
119 innerObj_ = std::make_optional<int>(root->valueint);
123 innerObj_ = std::make_optional<std::string>(root->valuestring);
127 innerObj_ = std::make_optional<bool>(root->type == cJSON_True);
136 if (root->string) {
137 key_ = root->string;