-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
老用户的观看权限 #725
Comments
#705 的继续。 |
users.json
需要从原有数据中拿到的是
这四项。 |
|
const fs = require('fs')
const removeLastEl = arr => arr.slice(0, -1)
const jsonToArr = json =>
json.map(t => {
return JSON.parse(t)
})
const getJson = path => removeLastEl(fs.readFileSync(path, 'utf-8').split('\n'))
const userArr = jsonToArr(getJson('../users.json'))
const selectEl = arr =>
arr.map(t => {
const { username, paidCourses, admin } = t
return {
username,
paidCourses,
member: admin
}
})
const arrToJson = arr => arr.map(t => JSON.stringify(t)).join('\n')
const userJson = arrToJson(selectEl(userArr))
const outputFile = 'contracts.json'
fs.writeFileSync(outputFile, userJson)
console.log('saved to ' + outputFile) |
总体思路是:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
导入一下
The text was updated successfully, but these errors were encountered: