This is a playground
to test code. It runs a full Node.js
environment and already has all of npm
’s 1,000,000+ packages pre-installed, including jsonstat
with all npm
packages installed. Try it out:
//Tonic Example File. For https://tonicdev.com
const
JSONstat = require('jsonstat'),
got = require("got"),
unr = function(arr){
got( "https://json-stat.org/samples/oecd.json" )
.then(response => {
var ds = JSONstat(JSON.parse(response.body));
if(ds.length){
arr.forEach(o => {
var
value = ds.Data(o).value,
label = (d => {
return ds.Dimension(d).Category(o[d]).label;
})
;
console.log(
"Unemployment rate in " +
label("area") + " in " +
label("year") + " was " +
value + " %."
);
});
}else{
console.log("Response is not valid JSON-stat.");
}
})
.catch(error => {
console.log(error.response.body);
})
;
}
;
//Time: 2003-2014 Geo: AU, AT, BE, CA...
unr([
{year: "2003", area: "DE"},
{year: "2003", area: "GR"}
]);
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.