-2

This should be pretty simple, I'm just pretty new to this. All I want to know how to do is how to display the following information from this file: http://worldoftanks.com/community/accounts/1003576349/api/1.8/?source_token=WG-WoT_Assistant-1.3.2

I want to display (for example purposes) the following using javascript:

  • -status
  • -vehicles -> spotted
  • -summary -> wins
  • -data -> defender

Thanks for any help!

Josh Woelfel
  • 1,919
  • 4
  • 17
  • 16

2 Answers2

2

Just deal with json as normal javascript object and access its properties/ arrays as you do for any other object. you can get the values that you are looking for like this. Fiddle

var json={...yourjson...};
alert('status ' + json.status);
alert('Spotted ' + json.data.vehicles[0].spotted);
alert('Wins ' + json.data.summary.wins);
alert('defender ' + json.data.achievements.defender);

For further dwelling look at this SO Post.

Community
  • 1
  • 1
PSL
  • 123,204
  • 21
  • 253
  • 243
1

You can use jQuery to parse Json

var output=jQuery.parseJSON(YOUR_JSON);

variable output will give you Object, From there you can easily extract data

document.write(output.query);
Vicky Gonsalves
  • 11,593
  • 2
  • 37
  • 58