on ‎2018 Jul 16 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
Request clarification before answering.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.