我当前的输出格式是
[{"label"=>"@mah", "value"=>"@mah"}, {"label"=>"@mahesh", "value"=>"@mahesh"}, {"label"=>"brand", "value"=>"brand"}]
但是我想要这种格式:
[{"label":"@mah", "value":"@mah"}, {"label":"@mahesh", "value":"@mahesh"}, {"label":"brand", "value":"brand"}]
有人可以帮我吗?
谢谢。
答案 0 :(得分:0)
您可以使用拆分和联接(功能)实现:
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.split(search).join(replacement);
};
var str='[{"label"=>"@mah", "value"=>"@mah"}, {"label"=>"@mahesh", "value"=>"@mahesh"}, {"label"=>"brand", "value"=>"brand"}]';
console.log(str);
console.log(str.replaceAll("=>", ":"));