【发布时间】:2012-11-22 10:11:49
【问题描述】:
我从 UI 获取数据如下,以下所有输入数据都是字符串。
cust_id : temp001 cust_chart_id : 测试 默认图表:假 chart_pref_json : {range:6m,chart_type:candlestick,indicators:{},period:Daily,futurepadding:20} }
我正在尝试将 chart_pref_json 存储在 mongodb 中。这个chart_pref_json对象其实是作为下面的字符串存储在db中的,
{ "_id" : ObjectId("50aca4caf5d0b0e4d31ef239"), "cust_id" : "temp001", "cust_chart_id" : "testing", "default_chart" : "false", "created_at" : NumberLong("1353491658551"), **"chart_pref_json" : "{range:6m,chart_type:candlestick,indicators:{},period:Daily,futurepadding:20}" }**
但我实际上希望将此 chart_pref_json 存储为 json 对象,如下所示。
{ "_id" : ObjectId("50aca4caf5d0b0e4d31ef239"), "cust_id" : "temp001", "cust_chart_id" : "testing", "default_chart" : "false", "created_at" : NumberLong("1353491658551"), **"chart_pref_json" : {range:6m,chart_type:candlestick,indicators:{},period:Daily,futurepadding:20} }**
谁能帮我解决这个问题。
【问题讨论】:
-
当我试图在 mongodb 中保存 "chart_pref_json" : {range:6m,chart_type:candlestick,indicators:{},period:Daily,futurepadding:20} } 时,它被保存为字符串 " {range:6m,chart_type:candlestick,indicators:{},period:Daily,futurepadding:20}" 而我想存储为 json {range:6m,chart_type:candlestick,indicators:{},period:Daily,futurepadding: 20} 没有“”。
-
想要的和不需要的结果看起来相同。