-1
我想解析儿子数据波纹管。我的代码适用于简单的儿子文件,但不适用于此代码。我尝试了许多不同的组合来获取我想要的数据。我不想得到标题和董事会栖息地,你以粗体显示。解析特殊的Json数据Javascript
我真的不知道我能做什么。
我的数据和JavaScript代码。
function loadData() {
var text = '{
"name": "",
"type": "",
"features": [{
"type": "",
"geometry": {
"type": "",
"coordinates": [279947.135830549, 356999.268696635]
},
"properties": {
"**title": "",
"timestamp": "",
"id": "",
"pos_acc": -1,
* * "Broad_Habi": "" * * ,
"geom_X": 53.09665139,
"geom_Y": -3.79436993599,
"Image": "",
"Name": "",
"Species_Id": "",
"Approx_Hei": "",
"Evidence_o": "",
"Distance_f": "",
"River_Bank": "",
"Describe_T": "",
"Describe_W": "",
"Field_Comm": "",
"Make_and_M": "",
"Azimuth": 145.238262662,
"editor": "",
"Pitch": -25.5942265843,
"OS_Version": "",
"Roll": 12.322497107 1
}
}, {
"type": "",
"geometry": {
"type": "",
"coordinates": [280443.642983406, 358907.166228556]
},
"properties": {
"title": "",
"timestamp": "",
"id": "",
"pos_acc": -1,
"Broad_Habi": "",
"geom_X": 53.1139046729,
"geom_Y": -3.78766989708,
"Image": "",
"Name": "",
"Species_Id": "",
"Approx_Hei": "",
"Evidence_o": "",
"Distance_f": "",
"River_Bank": "",
"Describe_T": "",
"Describe_W": "",
"Field_Comm": "",
"Make_and_M": "",
"Azimuth": 166.585854989,
"editor": "",
"Pitch": -48.7309271996,
"OS_Version": "",
"Roll": 8.1962176125 1
}
}]
}';
obj = JSON.parse(text);
console.log(obj.features.length);
for (var i = 0; i < obj.properties.length; i++) {
var currentObj = obj.properties.[i];
console.log(currentObj);
var mytitle = currentObj.title;
console.log(mytitle);
var habitat = currentObj.Broad_Habi;
console.log(habitat);
var table = document.getElementById("myTableData");
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
row.insertCell(0).innerHTML = '<input type="button" value = "Delete" onClick="Javacsript:deleteRow(this)">';
row.insertCell(1).innerHTML = mytitle;
row.insertCell(2).innerHTML = habitat;
}
}
**星星是唯一的堆栈溢出的页面,是不是在我的数据的情况下上。只是因为我想指出我想得到的数据。你知道我必须改变我的JavaScript代码才能获得标题和Board Habitat吗? – Ben