Created
March 6, 2023 19:18
-
-
Save szydan/b6ad9729fab246893b4769d9612cae85 to your computer and use it in GitHub Desktop.
json formatted to lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const inPath = process.argv[2]; | |
const outPath = process.argv[3]; | |
const content = fs.readFileSync(inPath); | |
const json = JSON.parse(content); | |
const hits = json.hits.hits; | |
const res = []; | |
for (const hit of hits) { | |
res.push(JSON.stringify(hit)); | |
} | |
const out = res.join("\n"); | |
fs.writeFileSync(outPath, res.join("\n")); | |
==================== | |
const fs = require("fs"); | |
const inPath = process.argv[2]; | |
const outPath = process.argv[3]; | |
const content = fs.readFileSync(inPath); | |
const json = JSON.parse(content); | |
fs.writeFileSync(outPath, JSON.stringify(json)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment