var v = [{"filename":"1.mp4","resname":"1280x720","videolength":"00:00:26.07"},{"filename":"2.mp4","resname":"854x480","videolength":"00:00:26.07"},{"filename":"3.mp4","resname":"640x360","videolength":"00:00:26.07"}];
我正在使用$.parseJSON(v);
但是有错误,有任何建议可以获得resname
的价值吗?
答案 0 :(得分:2)
无需解析v您可以通过不同方式访问它
一个是迭代或forloop
v.forEach(function (item, i) {
alert(item.resname)
});
您还可以使用
直接访问元素 alert(v[0].filename);
alert(v[1].filename);
答案 1 :(得分:2)
尝试:
var v = [{"filename":"1.mp4","resname":"1280x720","videolength":"00:00:26.07"},{"filename":"2.mp4","resname":"854x480","videolength":"00:00:26.07"},{"filename":"3.mp4","resname":"640x360","videolength":"00:00:26.07"}];
$.each(v,function (i, val) {
console.log(val.resname)
});