Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda