I want the regionValue to return as the key of the Region object, but it instead returns null?
My goal is to get:
{
value: 1122000,
Tid: '2020',
ContentsCode: 'Samlet inntekt, median (kr)',
HusholdType: 'Par med barn 0-17 år',
Region: 'Ringerike',
regionValue:"3007"
},
but this is what i've tried so far:
const JSONstat = require("jsonstat-toolkit");
var url="https://data.ssb.no/api/v0/dataset/49678.json?lang=no";
function test(){
return JSONstat(url).then(main);
}
async function main(j){
var ds=j.Dataset(0);
let y="Region"
let array = ds.toTable( { type : "arrobj" } ,function( d ){
if ( d.value!==null){
d.regionValue = ds.Dimension(y).Category(d.Region).id
return d;
}
})
console.log(array)
}
test()