更新时间:2022-03-16 22:29:07
如果无法更改此python字典,则可以使用解决方法:
If you cannot change this python dictionary, you can use a workaround:
var str = "[{u'total': '54', u'value': '54', u'label': u'14 Sep'}, {u'total': '58', u'value': '4', u'label': u'15 Sep'}, {u'total': '65', u'value': '7', u'label': u'16 Sep'}]";
str = str.replace(/u?'(.+?)': u?'(.+?)'/g, '"$1":"$2"');
console.log(str);
console.log(JSON.parse(str));