我從UI獲取數據如下,所有下面的輸入數據都是字符串。如何將字符串值作爲json對象存儲在mongo數據庫中?
CUST_ID:temp001 cust_chart_id:測試 default_chart:假 chart_pref_json:{範圍:6M,CHART_TYPE:燭臺,指標:{},週期:每日,futurepadding:20}}
我試圖存儲mongodb中的chart_pref_json。這chart_pref_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}" }**
但其實我是想這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} }**
任何人都可以幫助我解決這個問題。
當我試圖保存「chart_pref_json」:{range:6m,chart_type:燭臺,指標:{},句號:Daily,futurepadding:20}}在mongodb中,它保存爲字符串「{range:6m, chart_type:candlestick,指標:{},期間:Daily,futurepadding:20}「而不是我想要存儲爲json {範圍:6m,chart_type:燭臺,指標:{},期:Daily,futurepadding:20} 。 – Sandy