Bootstrap FreeKB - NodeJS - Parsing JSON using JSON.parse
NodeJS - Parsing JSON using JSON.parse

Updated:   |  NodeJS articles

Let's say you have a file named app.js that contains the following.

const json = '{"my_string": "Hello World", "my_boolean": true, "my_integer" :42}';
const obj = JSON.parse(json);

console.log(obj.my_string);
console.log(obj.my_boolean);
console.log(obj.my_integer);

 

If you use the node CLI to run app.js, the following should be displayed as stdout on your console.

~]$ node app.js
Hello World
true
42

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c970a5 in the box below so that we can be sure you are a human.