🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## json ``` { "status": "ok", "image_size_list": [ { "image_size_id": "22", "ad_class": "N" }, { "image_size_id": "19", "ad_class": "C" }, { "image_size_id": "24", "ad_class": "N" }, { "image_size_id": "15", "ad_class": "C" } ] } ``` ## HTML ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script> </head> <body> <script> $.getJSON('json1.json',function(data){ var dataNew = data; //采用filter过滤 dataNew.image_size_list = dataNew.image_size_list.filter(function(item){ return item.ad_class=='N'; });; }) </script> </body> </html> ``` ## 注意变化 虽然 `dataNew` 复制了一份 `data` ,但执行到最后,`data` 和 `dataNew` 都为两条数据!看动图: ![mark](http://qiniu.newthink.cc/blog/20171124-092939487.gif)