on 07-16-2018 4:16 PM
I want to "convert" a JSON Object to C++ model so that my tree will take the datta from C++ side.
I have a simple tree:
<Tree
id="Tree" items="{path: '/ftree'}">
<CustomTreeItem>
<Input value="{text}"/>
</CustomTreeItem>
</Tree>
Let's say I have this simple JSON
nodes:[{text:"Node1"},{text:"Node2",
nodes:[{text:"Node 2-1"}]}]
In C++ I have this structure:
struct nodes {
std::string text;
nodes()=default;
nodes(const std::string &text): text(text){}};
I also have a second "main" structure with a lot of other elements and it's like this:
structTree{
std::vector<nodes> ftree;}
In main I give the data:
Tree model;
model.ftree.push_back(nodes("Node 1"));
model.ftree.push_back(nodes("Node 2"));
model.ftree.push_back(nodes("Node 2-1"));
It's working but it takes all the nodes in the first level. How can I give data to a node inside?
Thank you
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.