【发布时间】:2014-09-24 09:35:59
【问题描述】:
我有一个字符串要转换成 json 字符串
下面是json的格式
title: {
position: "bottom",
text: "Share of Internet Population Growth"
},
legend: {
visible: false
},
chartArea: {
background: ""
},
seriesDefaults: {
type: "donut",
startAngle: 150
}
要将其转换为 JSON 字符串,我需要将 AnyKey: 替换为 "AnyKey":
我正在阅读有关 gsub 的信息。替换这种字符串的确切正则表达式是什么
提前致谢
【问题讨论】:
-
您只需执行
require 'json'然后your_hash.to_json.. 就完成了!阅读this doco。