I want to filter a json(get) from my supplier and export(post) to my Shop to update some fields of the products i have online. The problem is i can’t figure how to access the values i need. The values i need are:
id,
availability,
amount,
prot_lianiki
Example of 1 product contained in the JSON i need to filter:
{"products": {
"6416": {
"id": "",
"title": "",
"image": "",
"video": ,
"images": {
"51409": {
"pair_id": "",
"image_id": "",
"detailed_id": "",
"position": "",
"detailed": {
"image_path": "",
"alt": "",
"image_x": "",
"image_y": "",
"http_image_path": "",
"https_image_path": "",
"absolute_path": "",
"relative_path": ""
}
},
"51410": {
"pair_id": "",
"image_id": "",
"detailed_id": "",
"position": "",
"detailed": {
"image_path": "",
"alt": "",
"image_x": "",
"image_y": "",
"http_image_path": "",
"https_image_path": "",
"absolute_path": "",
"relative_path": ""
}
},
"51411": {
"pair_id": "",
"image_id": "",
"detailed_id": "",
"position": "",
"detailed": {
"image_path": "",
"alt": "",
"image_x": "",
"image_y": "",
"http_image_path": "",
"https_image_path": "",
"absolute_path": "",
"relative_path": ""
}
},
"51412": {
"pair_id": "",
"image_id": "",
"detailed_id": "",
"position": "",
"detailed": {
"image_path": "",
"alt": "",
"image_x": "",
"image_y": "",
"http_image_path": "",
"https_image_path": "",
"absolute_path": "",
"relative_path": ""
}
},
"51414": {
"pair_id": "",
"image_id": "",
"detailed_id": "",
"position": "",
"detailed": {
"image_path": "",
"alt": "",
"image_x": "",
"image_y": "",
"http_image_path": "",
"https_image_path": "",
"absolute_path": "",
"relative_path": ""
}
}
},
"sku": "",
"amount": "",
"weight": "",
"length": "",
"width": "",
"height": "",
"update": "",
"prot_lianiki": ,
"price": ,
"discount": "",
"list_price": "",
"promo_text": "",
"full_descr": "",
"availability": "",
"category_id": 2041,
"category_path": "",
"category_id_path": "",
"fixed_price": "",
"features": {
"162": {
"feature_name": "",
"feature_value_sel": "",
"feature_id": "",
"variant_id": ""
},
"1117": {
"feature_name": "",
"feature_value_sel": "",
"feature_id": "",
"variant_id": ""
},
"27": {
"feature_name": "",
"feature_value_sel": "",
"feature_id": "",
"variant_id": ""
}
}
}
}
My Code for loading the json to an array is:
pm.test(“array of all properties”, () => {
let jsonData = pm.response.json()
arrayOfObject = jsonData;
const obj = Object.assign({}, arrayOfObject);
console.log(obj);
});