Hi i am trying to do this
const request = require('request');
const zlib = require('zlib');
const opts = {
uri: 'http://data.githubarchive.org/2015-01-01-15.json.gz',
encoding: null,
};
request.get(opts, function(error, response, body) {
if (!error) {
zlib.gunzip(body, function(err, decoded) {
if (err) {
console.log(err)
} else {
var json_string = decoded.toString('utf-8').replace(/(\r\n|\n|\r)/gm, " ").trim();
var json = JSON.parse(json_string);
console.log("SJON", typeof json)
}
});
}
});
i am doing following steps
- fetching data from url
- unzip that using zlib.gunzip
- converting that decoded data to string
- replacing all newline and beak statements
- I am trying to parse that string which throws error
i am getting error while parsing data using JSON.parse. this is public dataset of github. i don't know where i am getting wrong can any one help.
via Rayees
No comments:
Post a Comment