• 11-10-2021, 18:05:29
    #1
    Birden fazla json dosyam var. Bunları tek dosyada birleştirmenin bir yolu var mıdır? txt olur json olur fark etmez
  • 11-10-2021, 18:07:14
    #2
    Üyeliği durduruldu
    Array ile birleştirebilirsiniz.
    [{"jsondatakey":"jsondata"}, {"json2datakey":"json2data"}]
  • 11-10-2021, 18:08:40
    #3
    bu şekilde nasıl yapılabilir? 400 küsur adet var
  • 11-10-2021, 18:12:59
    #4
    Mantığını yazacaktım sonra gittim yazacağım mantıkta olan kodu stackoverflow'dan buldum.
    const jsonConcat = require('json-concat');
    const fs = require('fs');
    
    // an array of filenames to concat
    const files = [];
    
    const theDirectory = __dirname; // or whatever directory you want to read
    fs.readdirSync(theDirectory).forEach((file) => {
      // you may want to filter these by extension, etc. to make sure they are JSON files
      files.push(file);
    })
    
    // pass the "files" to json concat
    jsonConcat({
      src: files,
      dest: "./result.json"
    }, function (json) {
      console.log(json);
    });
  • 11-10-2021, 19:14:14
    #5
    Eğer bir json'a yazdırmak yerine sadece array da birleştirecekseniz

    var json1 = [COLOR=#D9DAE9][FONT=Open Sans]require("./x.json")[/FONT][/COLOR]
    var json2 = [COLOR=#D9DAE9][FONT=Open Sans]require("./x.json")[/FONT][/COLOR] 
    var json3 = require("./x.json")
    
    var json = [...json1, ...json2, ...json3]
    console.log(json)
    gibi bir kullanım izleyebilirsiniz.