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