I am retrieving list item values in sharepoint using REST API.
Now I want to store these values in JSON so I can just call the JSON and retrieve the values in another function
$.ajax({
url: lib,
method: 'GET',
async: false,
headers: {"accept":"application/json;odata=verbose"},
success: function(data) {
/* console.log(data); */
if(data.d != undefined) {
var temp_prod= [];
$.each(data.d.results, function (i,item) {
}//each
} });
I want to construct the JSON to be like this
var products = [{ Dell Laptop: { price: 1000.00, color: black },
HP Laptop: { price: 900.00, color: grey }]
and can I access these using
var dellLaptopPrice = products["Dell Laptop"].price;
var dellLaptopColor = products["Dell Laptop"].color;