My question: I want to verify that in year 2020 , the population was 326569308 in the first response below. how i can create the test for this with postman
Details (like screenshots):
Json Response:
{
“data”: [
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2020,
“Year”: “2020”,
“Population”: 326569308,
“Slug Nation”: “united-states”
},
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2019,
“Year”: “2019”,
“Population”: 324697795,
“Slug Nation”: “united-states”
},
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2018,
“Year”: “2018”,
“Population”: 322903030,
“Slug Nation”: “united-states”
},
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2017,
“Year”: “2017”,
“Population”: 321004407,
“Slug Nation”: “united-states”
},
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2016,
“Year”: “2016”,
“Population”: 318558162,
“Slug Nation”: “united-states”
},
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2015,
“Year”: “2015”,
“Population”: 316515021,
“Slug Nation”: “united-states”
},
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2014,
“Year”: “2014”,
“Population”: 314107084,
“Slug Nation”: “united-states”
},
{
“ID Nation”: “01000US”,
“Nation”: “United States”,
“ID Year”: 2013,
“Year”: “2013”,
“Population”: 311536594,
“Slug Nation”: “united-states”
}
],
“source”: [
{
“measures”: [
“Population”
],
“annotations”: {
“source_name”: “Census Bureau”,
“source_description”: “The American Community Survey (ACS) is conducted by the US Census and sent to a portion of the population every year.”,
“dataset_name”: “ACS 5-year Estimate”,
“dataset_link”: “American Community Survey (ACS)”,
“table_id”: “B01003”,
“topic”: “Diversity”,
“subtopic”: “Demographics”
},
“name”: “acs_yg_total_population_5”,
“substitutions”:
}
]
}
How I found the problem:
I am new to this and still learning
I’ve already tried:
i have tried this by
var jsonData = pm.response.json();
for (subArray of jsonData){
for (subSubArray of subArray){
if (subSubArray.data.Year == ‘2020’){
pm.test(“population in 2020 was 326569308”, ()=>{
pm.expect(subSubArray.data.Population).to.eql(326569308)
})
}
}
but it is giving me an error TypeError: jsonData is not iterable