Skip to content

Instantly share code, notes, and snippets.

@cecilemuller
Last active December 21, 2015 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cecilemuller/14e168f7864ac66c61d3 to your computer and use it in GitHub Desktop.
Save cecilemuller/14e168f7864ac66c61d3 to your computer and use it in GitHub Desktop.
Read a nested property in a JSON5 scenegraph
'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);
}
);
{
"$": "Shape",
// This line is a comment.
"geometry": {
"$": "Sphere"
},
"appearance": {
"$": "Appearance",
"material": {
"$": "Material",
"diffuseColor": [0, 1, 0]
}
}
}
@cecilemuller
Copy link
Author

Example for Issue #10 of JSON Scenegraph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment