24 lines
730 B
JavaScript
24 lines
730 B
JavaScript
|
const fs = require('fs');
|
||
|
const path = require('path');
|
||
|
|
||
|
const DataFile = path.join(__dirname, './data.json')
|
||
|
const DataFile2 = path.join(__dirname, './data-friendly.json')
|
||
|
let data = JSON.parse(fs.readFileSync(DataFile, 'utf8'))
|
||
|
|
||
|
Object.keys(data).forEach(key => {
|
||
|
// data[key].radical = []
|
||
|
|
||
|
// 保证字典 key 顺序
|
||
|
data[key] = {
|
||
|
"word": data[key].word,
|
||
|
"pinyin": data[key].pinyin,
|
||
|
"radical": [],
|
||
|
"stroke": data[key].stroke,
|
||
|
"type": data[key].type,
|
||
|
"from": data[key].from,
|
||
|
"confirm": data[key].confirm
|
||
|
}
|
||
|
})
|
||
|
|
||
|
fs.writeFileSync(DataFile, JSON.stringify(data), 'utf8')
|
||
|
fs.writeFileSync(DataFile2, JSON.stringify(data, null, 4), 'utf8')
|