I am working on a modified version of this application
I added different type of link to the program, I want to add what kind of link the edges are in the JSON document, but when I enter this information as text:
{"nodes":
[
{"id":2,"title":"1","x":181,"y":146},
{"id":3,"title":"2","x":608,"y":153},
{"id":4,"title":"3","x":153,"y":398},
{"id":5,"title":"4","x":548,"y":405}
]
,"edges":
[
{"source":2,"target":3,"typeLink":"arrow"},
{"source":4,"target":5,"typeLink":"circle-full-blue"},
{"source":5,"target":3,"typeLink":"circle_square-hollow-blue"}
]
}
The json document that comes out of it is missing the "typeLink" information :
0: Object { source: {…}, target: {…} }
I didn't modified the original code, except for console log :
d3.select("#upload-input").on("click", function(){
document.getElementById("hidden-file-upload").click();
});
d3.select("#hidden-file-upload").on("change", function(){
if (window.File && window.FileReader && window.FileList && window.Blob) {
var uploadFile = this.files[0];
var filereader = new window.FileReader();
filereader.onload = function(){
var txtRes = filereader.result;
console.log("#TXT : ");
console.log(txtRes);
// TODO better error handling
try{
var jsonObj = JSON.parse(txtRes);//missing typeLink
console.log("#JSON : ");
console.log(jsonObj);
I also had this same issue before, json to String format for some reason can be missing some information. To fix this:
JSON.stringify(json) => Will turn json into String format, no info missing
JSON.parse(string) => Will turn String into json format, no info missing
Try using those functions as you need and see if that works.