Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Missing information from text to JSON

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); 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!