Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert implementations.json into new style
// `orig.json` is copied from:
// https://raw.githubusercontent.com/tableflip/libp2p-website/56ff92f5ac93114ca9e1b4d03d98f509a73bc5b5/data/implementations.json
const data = require('./orig.json')
const langNames = ['Browser JS', 'Node.js', 'Go']
const res = Object.keys(data).map(categoryName => {
const category = data[categoryName]
const libs = Object.keys(category).map(libName => {
const lib = category[libName]
return {
id: libName,
langs: langNames.map(langName => {
const impl = lib[langName] || {}
return {
name: langName,
status: impl.status || 'Missing',
url: impl.url || ''
}
})
}
})
return {
id: categoryName,
libs
}
})
console.log(JSON.stringify(res, null, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment