-1

I have this response from the github api:

Status: 200 OK

{
  "C": 78769,
  "Python": 7769
}

How can I do to iterate over this without knowing which language do I have..? and access the value of each language.. because "C" and "Python" are not constants.

Thanks for reading.

  • 1
    Json is a string that can be *deserialized* into an object that you can easily work with. Once deserialized it is no longer Json. Try searching how to iterate over an object. :) – GolezTrol Sep 01 '17 at 17:44
  • 1
    Combine [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse), [`Object.keys`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys), and [`[].forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) – ryanve Sep 01 '17 at 18:00

1 Answers1

1
var jsonOBJ = {
  "C": 78769,
  "Python": 7769
}

for(var prop in jsonOBJ){
  console.log(json[prop])
}
TimCodes
  • 365
  • 2
  • 14