Last active
January 18, 2019 11:01
-
-
Save varmais/a4217ef387c39304e08c75286d474f55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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