Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
Hereโs an outline with best practices for making your inquiry.
My question:
How do I extract all product_id from this json file?
I had try on some related post with same question but I can not find the results as expected.
Details (like screenshots):
{
"code": 200,
"message": "Success",
"data": {
"data_item": [{
"name": "A",
"prefixes": [
"p1",
"p2"
],
"products": [{
"product_id": 2442793,
"name": "BBB",
}, {
"product_id": 2443085,
"name": "AAA",
}, {
"product_id": 2443089,
"name": "90A",
}, {
"product_id": 2443091,
"name": "VVV",
}
]
}, {
"name": "B",
"prefixes": [
"p1",
"p2",
],
"products": [{
"product_id": 24427933421,
"name": "VB",
}, {
"product_id": 24434373332,
"name": "GG",
}, {
"product_id": 2443094333,
"name": "ABC",
}, {
"product_id": 244332095,
"name": "1da",
}, {
"product_id": 244435937,
"name": "KA",
}
]
}, {
"name": "C",
"prefixes": [
"p1",
"p2",
],
"products": [{
"product_id": 232499,
"name": "10A",
}, {
"product_id": 42643101,
"name": "20A",
}, {
"product_id": 24443503,
"name": "30A",
}, {
"product_id": 244435105,
"name": "40A",
}, {
"product_id": 244345107,
"name": "50A",
}
]
}
}
}
How I found the problem:
Iโve already tried:
const response = pm.response.json();
let lstprod =
_.each(lstproducts.data_item, (result) => {
lstprod.push(result.products);
})
const Ids = lstprod .map(x => x.product_id)