dimanche 19 avril 2015

parse JSON containing an array in NodeJS

I have to parse a json file containing an array into a NodeJS program:


My json file:





{
"name":"M"
"types":[
"al",
"pouf",
"k"
]
}



I read the JSON file into my NodeJS program using:



var my_json = require(./json);


But I have this error message:



Unexpected string
at Object.parse (native)
at Object.Module._etensions..json (module.js:486:27)
at Module.load (module.js:310:12)

Aucun commentaire:

Enregistrer un commentaire