如何检查ndjson格式验证?

时间:2019-07-11 18:43:33

标签: node.js express ndjson

因此,我已得到一个要导入的NDJSON文件,然后将其显示在表格的网页上。我一直在数据内部出现错误,并且对格式感到满意。我将删除有问题的变量,然后继续进行下一个。

我尝试查看npm ndjson,但感到困惑,因为关于实现的解释不多。

Observation.ndjson

{"resourceType": "Observation", "id":"35i123", "status": "final", "category":[{"coding":[.........]}]}
{"resourceType":"Observation"......}

index.js

var transformStream= ndjson.stringify();
var outputStream = transformStream.pipe(fileSystem.createReadStream("./Observation.ndjson"));
outputStream.on(
"finish", function handleFinish(){
console.log("ndjson serialize completed!");
}
);

outputStream.on(
"finish", function handleFinish() {
var inputStream = fileSystem.createReadStream(__dirname + "./Observation.ndjson")
var transformStream=inputStream.pipe(ndjson.parse("./Observation.ndjson"));
transformStream
             .on( "data", function handleRecord(data){
             function handleRecord(data){
              console.log("record(event):", data);
         } 
      }
   )
        .on("end", function handleEnd(){
         console.log("ndjson parsing complete!");
      }
  )
;
}
);

0 个答案:

没有答案