2018年3月16日 星期五

[Node.js] How to Parse the JSON keywork out

Code
// Define JSON File
var fs = require("fs");
// Get content from file
var contents = fs.readFileSync("tmp.json");
// Define to JSON type
var jsonContent = JSON.parse(contents);
// Get Value from JSON

console.log("Device:", jsonContent.result.parameters.device);

console.log("State:", jsonContent.result.parameters.state);

Ref:

0 意見:

張貼留言