日期:2014-05-16  浏览次数:20609 次

JS去重json数据(大婶快来)
本帖最后由 san13219091 于 2014-03-22 11:46:09 编辑

{                                                      
"total":3,                                                      
"rows":[                                                          
{"code":"001","name":"北京市","qymc":"雪花啤酒","pfkmc":"雪花排气口1#"},         
{"code":"002","name":"北京市","qymc":"雪花啤酒","pfkmc":"雪花排气口2#"},         
{"code":"003","name":"上海市","qymc":"雪花啤酒","pfkmc":"雪花排气口2#"}
]                                                          
}   


需求:name重复的json 只留一条,就是如果name相同就去重,生成一个新的json
------解决方案--------------------
	var $a ={                                                      
    "total":3,                                                      
    "rows":[                                                          
        {"code":"001","name":"北京市","qymc":"雪花啤酒","pfkmc":"雪花排气口1#"},         
        {"code":"002","name":"北京市","qymc":"雪花啤酒","pfkmc":"雪花排气口2#"},         
        {"code":"003","name":"上海市","qymc":"雪花啤酒","pfkmc":"雪花排气口2#"}
    ]