Hello I have the following Javascript code where I try to convert the object obtained from Neo4J database into a nice array or JSON (I'll be able to deal with one of the two) for further use with Gephi / Sigma.
But it doesn't work...
Any idea why?
var myObj = [
[ 'b7145841-962f-11e3-8b8e-abca0f9fdedd',
'painquotidien',
'b7145842-962f-11e3-8b8e-abca0f9fdedd',
'cafeamour',
'b7145843-962f-11e3-8b8e-abca0f9fdedd' ],
[ 'cce97c91-962f-11e3-8b8e-abca0f9fdedd',
'hotelamour',
'b7145842-962f-11e3-8b8e-abca0f9fdedd',
'cafeamour',
'19fe2713-9630-11e3-8b8e-abca0f9fdedd' ]
];
var nodes = {
id: '',
label: ''
};
var edges = {
source: '',
target: '',
id: ''
};
for (var i = 0; i < myObj.length; i++) {
nodes['id'].push(myObj[i][0]);
nodes['label'].push(myObj[i][1]);
nodes['id'].push(myObj[i][2]);
nodes['label'].push(myObj[i][3]);
edges['source'].push(myObj[i][0]);
edges['target'].push(myObj[i][2]);
edges['id'].push(myObj[i][4]);
}
Already searched on StackOverflow and elsewhere, but none of the solutions provided worked for me, probably because it's a multi-dimensional array that I need and of a slightly different structure than the object (see the code above).
Thank you for your help!