Skip to content

Instantly share code, notes, and snippets.

@matsuhisa
Created September 27, 2015 08:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsuhisa/81fb41ee3e3475fdd906 to your computer and use it in GitHub Desktop.
Save matsuhisa/81fb41ee3e3475fdd906 to your computer and use it in GitHub Desktop.
node.js でのjsonファイルの読み込み
var fs = require('fs');
var json = JSON.parse(fs.readFileSync('./test.json', 'utf8'));
console.log(json.marker[0].name);
@matsuhisa
Copy link
Author

読み込んだJsonファイルは

{
  "marker":[
    {"lat":41.772596,"lng":140.725261,"name":"函館朝市"},
    {"lat":41.796864,"lng":140.756965,"name":"五稜郭"},
    {"lat":41.772912,"lng":140.816231,"name":"函館空港"}
  ]
}

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