trusov.vlad Posted November 9, 2017 Posted November 9, 2017 I'm trying to find out how to set an array as a value of json node. I can't understand how to use setArray() without argument, and on the "c++" tab of related page of documentation only example for UnigineScript are given.
fox Posted November 9, 2017 Posted November 9, 2017 Hello Vlad! Unfortunately, there seems to be a bug in documentation. The setArray() method for C++ only sets the type for the current Json node, the values of the elements should be added via the addChild() methods. // creating a Json JsonPtr json = Json::create(); // adding a child Json element named "array" to the parent json JsonPtr array = json->addChild("array"); // setting array type for the Json element array->setArray(); // adding array elements array->addChild(NULL, 1); array->addChild(NULL, 2); array->addChild(NULL, "3"); array->addChild(NULL, "data_0"); array->addChild(NULL, 5); We apologize for the inconvenience caused, and we'll fix this bug as soon as possible! Thank You for reporting this issue! 1
Recommended Posts