-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreduce-size.js
More file actions
31 lines (27 loc) · 801 Bytes
/
reduce-size.js
File metadata and controls
31 lines (27 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require("fs");
const path = require("path");
const inputFilePath = path.join(__dirname, "data", "postcode-lat-long.json");
const outputFilePath = path.join(
__dirname,
"data",
"postcode-lat-long-min.json"
);
fs.readFile(inputFilePath, "utf8", (err, data) => {
if (err) {
console.error("Error reading the file:", err);
return;
}
try {
const jsonData = JSON.parse(data);
const minifiedData = JSON.stringify(jsonData);
fs.writeFile(outputFilePath, minifiedData, "utf8", (err) => {
if (err) {
console.error("Error writing the minified file:", err);
return;
}
console.log(`Minified JSON file created at: ${outputFilePath}`);
});
} catch (parseErr) {
console.error("Error parsing the JSON file:", parseErr);
}
});