Last active
December 21, 2015 22:09
-
-
Save cecilemuller/14e168f7864ac66c61d3 to your computer and use it in GitHub Desktop.
Read a nested property in a JSON5 scenegraph
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
'use strict'; | |
const fs = require('fs'); | |
const json5 = require('json5'); | |
fs.readFile( | |
'scene.json5', | |
'utf8', | |
(error, code) => { | |
const shape = json5.parse(code); | |
console.log(shape.appearance.material.diffuseColor); | |
} | |
); |
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
{ | |
"$": "Shape", | |
// This line is a comment. | |
"geometry": { | |
"$": "Sphere" | |
}, | |
"appearance": { | |
"$": "Appearance", | |
"material": { | |
"$": "Material", | |
"diffuseColor": [0, 1, 0] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for Issue #10 of JSON Scenegraph.