By using node js I generate the array below, by parsing through multiple json files for a particular value.
When we get" content is true" mean that the particular id is available, when it's "undefined or anythoing else" should mean it's un available.
I wanna write a loop where. I recover the first file name with its status available or not and then go through my array and only recover the next value if the status changes ( if it goes for example from true to undefined)
So here is part of my code where I generate this file :
Promise.mapSeries(filenames, function(fileName) {
var contents = fs
.readFileAsync("./availibility/" + fileName, "utf8")
.catch(function ignore() {});
return Promise.join(contents, function(contents) {
return {
fileName,
contents
};
});
}).each(function(eachfile) {
if(eachfile.contents){
jsonobject = JSON.parse(eachfile.contents);
if(jsonobject && jsonobject.hasOwnProperty('messages'))
// console.log(jsonobject.messages[0].message.results[2]);
eachfile.contents = jsonobject.messages[0].message.results[1].isAvailable;
}
eachfile.fileName = eachfile.fileName.substring('revision_'.length,(eachfile.fileName.length-5));
console.log(eachfile);
})
May someone help me please
Thank you,
via Marou Aityahia
No comments:
Post a Comment