Skip to content

Instantly share code, notes, and snippets.

@oscarr-reyes
Created October 31, 2016 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarr-reyes/43555c13d279ae556c6c2ce4b5c32e7b to your computer and use it in GitHub Desktop.
Save oscarr-reyes/43555c13d279ae556c6c2ce4b5c32e7b to your computer and use it in GitHub Desktop.
var data = {
"id": "3",
"create_at": "2016-10-15 05:28:10",
"account": {
"username": "mgrantbt"
},
"ticket": {
"status_id": "2"
},
"amount": {
"name": "Equaline",
"number": "13"
},
"childs": [
{
"ancestor": "3",
"descendant": "6",
"username": "lbennettmk"
},
{
"ancestor": "3",
"descendant": "7",
"username": "gricehj"
},
{
"ancestor": "6",
"descendant": "12",
"username": "rcarroll8y"
},
{
"ancestor": "6",
"descendant": "1002",
"username": "jdunn4t"
},
{
"ancestor": "7",
"descendant": "1003",
"username": "jdunn4t"
}
]
};
var nodes = [],
relations = [];
for(child in data.childs){
nodes.push({
id: data.childs[child].ancestor,
name: data.childs[child].usernaeme
});
relations.push({
parent: data.childs[child].ancestor,
child: data.childs[child].descendant
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment