23 #include "JSONElement.h"
25 JSONElement::JSONElement() {
30 JSONElement::~JSONElement() {
35 this->children.push_back(child);
36 if(child->name!=
"" && this->type!=JSON_ARRAY)
38 this->allnodes[child->name] = child;
42 int JSONElement::getType()
const {
46 void JSONElement::setType(
int type) {
50 string JSONElement::getValue()
const {
54 bool JSONElement::hasChildren() {
55 return this->children.size()>0;
58 void JSONElement::setValue(
string value) {
62 string JSONElement::getName()
const {
66 vector<JSONElement*> JSONElement::getChildren() {
67 return this->children;
70 void JSONElement::setName(
string name) {
74 JSONElement* JSONElement::getNode(
const string& name) {
75 if(allnodes.find(name)!=allnodes.end())
76 return allnodes[name];
80 string JSONElement::toString()
82 string txt =
"[name=" + name;
83 txt +=
", value=" + value;
84 txt +=
", children={";
85 for (
int var = 0; var < (int)children.size(); ++var) {
86 txt += children.at(var)->toString();