-4

I'm not getting how to parse finance.google.com results, i.e. I got

[  
   {  
      "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"
   }
]

when I made call to this endpoint using httpopenConnection method, I didn't get anything returned because I couldn't find the JSON object name and i am going to use the result in my android app.

Gireesh Bhat
  • 139
  • 1
  • 1
  • 7
  • What do you mean by ‘*the json object name*’? That's JSON, parse it and you will have your data. You'll have to be more specific about what your problem is. – Biffen Sep 24 '16 at 08:53
  • yeah, you're right, too early. – RigidBody Sep 24 '16 at 08:55
  • 1
    We're not too keen on `plz` and `tq` here, because it should not be too much effort to type "please" and "thank you". Please try to use real words when posting, thank you! – halfer Sep 24 '16 at 09:54

1 Answers1

-1

Assuming js is your tool of choice, and you since you don't say what you're trying to do with the array, just assign to a var named obj and you can access it - loop as required...

<!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":"&#8377;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>

Resulting output to browser is:

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
RigidBody
  • 656
  • 3
  • 11
  • 26