把json串中“:”前面名称部分的双引号去掉,值中的双引号保留

原字符串:
[{'y': 2, 'url': '/disaster/collect/1/', 'name': u'\u9707\u611f'}, {'y': 0, 'url': '/disaster/collect/2/', 'name': u'\u5efa\u7b51\u7269\u7834\u574f'}, {'y': 0, 'url': '/disaster/collect/3/', 'name': u'\u4eba\u53e3\u5f71\u54cd'}, {'y': 1, 'url': '/disaster/collect/4/', 'name': u'\u5c45\u6c11\u751f\u6d3b\u5f71\u54cd'}, {'y': 0, 'url': '/disaster/collect/5/', 'name': u'\u4ea4\u901a\u7cfb\u7edf\u5f71\u54cd'}, {'y': 0, 'url': '/disaster/collect/6/', 'name': u'\u6b21\u751f\u707e\u5bb3'}, {'y': 0, 'url': '/disaster/collect/7/', 'name': u'\u5730\u9762\u7834\u574f'}]
需要的字符串:
[{y: 2, url: '/disaster/collect/1/', name: u'\u9707\u611f'}, {y: 0, url: '/disaster/collect/2/', name: u'\u5efa\u7b51\u7269\u7834\u574f'}, {y: 0, url: '/disaster/collect/3/', name: u'\u4eba\u53e3\u5f71\u54cd'}, {y: 1, url: '/disaster/collect/4/', name: u'\u5c45\u6c11\u751f\u6d3b\u5f71\u54cd'}, {y: 0, url: '/disaster/collect/5/', name: u'\u4ea4\u901a\u7cfb\u7edf\u5f71\u54cd'}, {y: 0, url: '/disaster/collect/6/', name: u'\u6b21\u751f\u707e\u5bb3'}, {y: 0, url: '/disaster/collect/7/', name: u'\u5730\u9762\u7834\u574f'}]
# 正则匹配替换
str = str.replace(/"(\w+)":/g, "$1:");

你可能感兴趣的:(js/jquery,bootstrap)