This code works:
var nodes_object = myObj;
var g = {
nodes: [],
edges: []
};
for (var i = 0; i < nodes_object.length; i++) {
g.nodes.push({
id: nodes_object[i][0],
label: nodes_object[i][1]
});
g.nodes.push({
id: nodes_object[i][2],
label: nodes_object[i][3]
});
g.edges.push({
source: nodes_object[i][0],
target: nodes_object[i][2],
id: nodes_object[i][4],
edge_context: nodes_object[i][5]
});
};