There are many country codes in this json file. I only want country codes "TWN" and "HK". I understand that TWN and HK are the object.key. however i also want to retrieve whatever that is inside the country code - e.g. the object.value of TWN
Can someone help me? I cant seem to get the results that i want. This in react native language and this is the json file https://covid.ourworldindata.org/data/owid-covid-data.json . Can someone help me?
Asked
Active
Viewed 121 times
-1

mathsmad
- 55
- 6
-
1[`Object.keys(data)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)? – Andy Jun 14 '21 at 13:08
1 Answers
0
You are trying to get the keys of the overall object.
All you need is the Object.keys()
function.
const owid = {"AFG":{x:1, y:2}, "CA":{a:3, b:4}};
const countryCodes = Object.keys(owid);
console.log(countryCodes)

Andy
- 61,948
- 13
- 68
- 95

ProfDFrancis
- 8,816
- 1
- 17
- 26
-
Hi, i understood it but i want to get the data for countryCodes too. for example i want AFG object data too. is there a way? – mathsmad Jun 14 '21 at 13:13