Reputation: 179
I have here a JSON object having an array of data. My issue is how could I get the array data to export it to excel? I'm currently using alaSql for this.
{
a: 'test',
b: [
{c:'test1',
d: 'test2'},
{c:'test2', d: 'test1'}]
}
Upvotes: 1
Views: 1291
Reputation: 4107
To traverse nested JSON object you need to use AlaSQL's SEARCH operator like below:
var data = [
{
a: 'test',
b: [
{c:'test1',
d: 'test2'},
{c:'test2', d: 'test1'}]
},
{
a: 'testB',
b: [
{c:'test3',
d: 'test4'},
{c:'test5', d: 'test6'}]
}
];
var res = alasql('SEARCH / AS @p b / CLONEDEEP() SET(a=@p->a) \
INTO XLSX("restest390a.xlsx",{headers:true}) FROM ?',[data])
In this statement AlaSQL:
Upvotes: 1