Does anyone know how to modify the labels in a JSON Array?
Lets say my array is:
[{"Device_ID":"43","Image":"Amazon-Kindle-Fire.png","Manufacturer":"Amazon","Model":"Kindle Fire","Type":"Tablet"},{"Device_ID":"43","Image":"Apple-iPad.png","Manufacturer":"Apple","Model":"iPad","Type":"Tablet"}]
How can I manipulate it so that Device_ID becomes label and the combination of Manufacturer and Model becomes values?
This is required for the jquery autocomplete and I am unable to modify the current JSON Array at source
UPDATE:
Currently attempting this way with no success:
$(function() {
var availableTags = <?php echo json_encode($results); ?>;
var john = availableTags.forEach(function(v){v.Device_ID = v.Manufacturer + v.Model});
$("#search_input").autocomplete({
source: john;
});
});
try that:
it will loop for every object in the array and assign the id to the combination you need.