Skip to content

Instantly share code, notes, and snippets.

@varmais
Last active January 18, 2019 11:01
Show Gist options
  • Save varmais/a4217ef387c39304e08c75286d474f55 to your computer and use it in GitHub Desktop.
Save varmais/a4217ef387c39304e08c75286d474f55 to your computer and use it in GitHub Desktop.
const fs = require('fs')
const data = require('./source.json')
function writeFile(filename, content) {
fs.writeFileSync(filename, content)
}
function removeNulls (list) {
return list.filter(item => !!item)
}
writeFile('first.json', JSON.stringify(data.glossary))
writeFile('second.json', JSON.stringify(removeNulls(data.items)))
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
},
"items": [
{"id": "Open"},
{"id": "OpenNew", "label": "Open New"},
null,
{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"},
null,
{"id": "Quality"},
{"id": "Pause"},
{"id": "Mute"},
null,
{"id": "Find", "label": "Find..."},
{"id": "FindAgain", "label": "Find Again"},
{"id": "Copy"},
{"id": "CopyAgain", "label": "Copy Again"},
{"id": "CopySVG", "label": "Copy SVG"},
{"id": "ViewSVG", "label": "View SVG"},
{"id": "ViewSource", "label": "View Source"},
{"id": "SaveAs", "label": "Save As"},
null,
{"id": "Help"},
{"id": "About", "label": "About Adobe CVG Viewer..."}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment