我有如下的JSON数据。
// Deletes textelemnt
function DeleteT(num) {
localStorage.removeItem("txt" + num);
localStorage.removeItem("h" + num);
console.log('del');
i=i-1;
var now = localStorage.getItem("AllNum");
if((now-1)<0){
now=0;
localStorage.setItem("AllNum", (0));
}else{
localStorage.setItem("AllNum", (now-1));
}
$("div.textarea" + num).remove();
}
//Loads all the text elemnts with a for loop until the number of areas is reached
function load() {
if (document.getElementById("alltxt").childElementCount < localStorage.getItem('AllNum')) {
for (var i = 1; i <= localStorage.getItem('AllNum'); i++) {
$('#alltxt').append('<div class="textarea' + i + '"><input onkeyup="save()" id="h' + i + '"></input><textarea onkeyup="save()" id="txt' + i + '"></textarea></br><button onClick="cut(txt' + i + ')" class="f b">Cut</button> <button onClick="copy(txt' + i + ')" class="f b">Copy</button> <button onClick="speak(txt' + i + ')" class="f b">Speak</button> <button onClick="download(' + i + ')" class="f a">Save</button><button onClick="textFull(' + i + ')" class="f">Fullscreen</button> <button onClick="DeleteT(' + i + ')" class="f">Delete</button> </div>');
document.getElementById('txt' + i).innerHTML = localStorage.getItem("txt" + i);
document.getElementById("h" + i).setAttribute('value', localStorage.getItem("h" + i));
}
}
}
我想动态提取访问数组值。
与下面类似:(管道消亡的柱)
{
"userid": null,
"appnumber": "9",
"trailid": "1547383536",
"visit": [{
"visitNumber": "1",
"time": "0",
"hour": "18",
"minute": "15"
},
{
"visitNumber": "2",
"time": "2942",
"hour": "18",
"minute": "15"
}
]
}
如果您看到我在visit数组中有2个json元素。所以我想动态提取visitNumber,时间,小时,分钟。有时我在数组中可能有3或5个值,因此它应该自动提取所有3或5个json(我是动态地表示)。
我要在AWS Athena上运行它,或者可能在Pig Cluster中。
有人可以帮我进行精确查询吗?
答案 0 :(得分:0)
您可以使用以下方法,但是即使在这种情况下,所有数组条目也将属于不同行的一部分。
select
userid,
appnumber,
trailid,
d.visitnumber,
d.time,
d.hour ,
d.minute
FROM table t1
LATERAL VIEW OUTER EXPLODE (visit) collection as d;