javascript - Unable to access an object in json(array of object) -


i have gulp task trying read json file(array of objects) , want write single object file.

json:

    {     "files": [{         "dev": {             "poibasepath": "poi",             "basepathsearch": "search-v1",             "contenttype": "application/json",             "timeout": 10000         }     }, {         "qa": {             "poibasepath": "poi",             "basepathsearch": "search-v1",             "contenttype": "application/json",             "timeout": 10000         }     }] } 

gulp task:

    gulp.task('readfile', function() {     return gulp.src('app/dataconfig.json')         .pipe(fs.readfile("app/dataconfig.json", "utf-8", function(err, data){             console.log(data);//getting total json object here             fs.writefile('app/scripts/apiconfig.js', data.files[0].dev);         }))         .pipe(gulp.dest('./dest/')) }) 

here when trying access data.files[0].dev getting undefined

any appreciated


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -