我没有得到如何解析finance.google.com结果,即我得到了
[
{
"id":"787381",
"t":"HDFC",
"e":"NSE",
"l":"1,424.00",
"l_fix":"1424.00",
"l_cur":"₹1,424.00",
"s":"0",
"ltt":"3:46PM GMT+5:30",
"lt":"Sep 23, 3:46PM GMT+5:30",
"lt_dts":"2016-09-23T15:46:54Z",
"c":"+10.75",
"c_fix":"10.75",
"cp":"0.76",
"cp_fix":"0.76",
"ccol":"chg",
"pcls_fix":"1413.25"
}
]
当我使用httpopenConnection方法调用this endpoint时,我没有得到任何返回,因为我找不到JSON对象名称,我将在我的Android应用程序中使用结果。
答案 0 :(得分:-1)
假设js是你选择的工具,而且你没有说明你要对数组做什么,只需指定一个名为obj
的var并且你可以访问它 - 根据需要循环...
<!DOCTYPE HTML>
<html>
<body>
<h2>Manage a JSON Object in JavaScript</h2>
<p id="demo"></p>
<script>
var obj = [{"id":"787381","t":"HDFC","e":"NSE","l":"1,424.00","l_fix":"1424.00","l_cur":"₹1,424.00","s":"0","ltt":"3:46PM GMT+5:30","lt":"Sep 23, 3:46PM GMT+5:30","lt_dts":"2016-09-23T15:46:54Z","c":"+10.75","c_fix":"10.75","cp":"0.76","cp_fix":"0.76","ccol":"chg","pcls_fix":"1413.25"}];
document.getElementById("demo").innerHTML =
obj[0].id + "<br>" +
obj[0].t + "<br>" +
obj[0].e + "<br>" +
obj[0].l + "<br>" +
obj[0].l_fix + "<br>" +
obj[0].l_cur + "<br>" +
obj[0].s + "<br>" +
obj[0].ltt + "<br>" +
obj[0].lt + "<br>" +
obj[0].lt_dts + "<br>" +
obj[0].c + "<br>" +
obj[0].c_fix + "<br>" +
obj[0].cp + "<br>" +
obj[0].cp_fix + "<br>" +
obj[0].ccol + "<br>" +
obj[0].pcls_fix + "<br>";
</script>
</body>
</html>
结果输出到浏览器是:
Accessing a JSON Object in JavaScript
787381
HDFC
NSE
1,424.00
1424.00
₹1,424.00
0
3:46PM GMT+5:30
Sep 23, 3:46PM GMT+5:30
2016-09-23T15:46:54Z
+10.75
10.75
0.76
0.76
chg
1413.25