Node.js - Parsing JSON using JSON.parse

by
Jeremy Canfield |
Updated: July 22 2024
| Node.js 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