Sunday 14 January 2018

How to use a JSON array after requiring the file?

Hello, I have an issue with a JSON file, I have been searching around various other sources of code and found that requiring the JSON file should just work as they did not have to parse it or use fs.Here is the issue:My Code:JSON: { "AdminID": ["101"] }Node.JS:const config = require("./config.json"); var admin = config.AdminID; if(admin == "101"){ console.log("True"); }else{ console.log("False"); }; Console: FalseI want it to display True instead of false because the adminID in the JSON file is the exact same as what is written in the program however for some reason no matter what I try it doesn't work.I need the adminID to be a JSON array as I have planned to add more but for at the moment, to keep it simple I have just kept it with one.

Submitted January 14, 2018 at 11:24AM by nightfuryninja1

No comments:

Post a Comment