My question:
Hi guys,
how do I receive a response.json in the postman with only this answers “produto_codigo_tamanho” and “qtd”?
i just need response.json something like this to include in my workbench on postgres:
There must be a way?
I’ve already tried:
but I just need “produto_codigo_tamanho” and “qtd” and this command returns all this:
JSON.parse and pm.response.json() creates a JavaScript object.
You can create a new object that just shows the two elements you are interested in using the JavaScript map function.
Something like.
// the following is a JavaScript object, and should be the same format as
// var jsonData = pm.response.json();
var jsonData = {
"stock": [
{
"produto_codigo_tamanho": "28899236",
"qtd": "0",
"cod_loja": "1",
},
{
"produto_codigo_tamanho": "28676534",
"qtd": "1",
"cod_loja": "1",
},
{
"produto_codigo_tamanho": "28906634",
"qtd": "2",
"cod_loja": "1",
}
]
}
var object = jsonData.stock.map(({ produto_codigo_tamanho, qtd }) => ({ produto_codigo_tamanho, qtd }));
console.log(object);
The results in the Console Log showing the 3 records but without cod_loja
1 Like