用js解析器解析json数据并写上条件语句
var x =$data;
var column = Object.keys(x.data[0]);
var content = [];
for (var i = 0; i < x.data.length; i++) {
if (x.data[i].field1== 3) { //条件语句,筛选field1为3的数据
var contentLine = [];
contentLine.push(x.data[i].field1,
x.data[i].field2,
x.data[i].field3,
x.data[i].field4,
x.data[i].field5);
content.push(contentLine);
}
}
var result = {};
result.column = column;
result.content = content;
return result;