有谁知道如何修改 JSON 数组中的标签?
可以说我的数组是:
[{"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"}]
如何操作它,以便 Device_ID 成为标签,制造商和型号的组合成为值?
这是 jquery 自动完成所必需的,我无法在源代码中修改当前 JSON 数组
更新:
目前尝试这种方式没有成功:
$(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;
});
});