Skip to content

Instantly share code, notes, and snippets.

@olizilla
Created June 14, 2017 12:07
Show Gist options
  • Save olizilla/21bbae3bf1098f5037b6cf4b5a3acdad to your computer and use it in GitHub Desktop.
Save olizilla/21bbae3bf1098f5037b6cf4b5a3acdad to your computer and use it in GitHub Desktop.
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