0
我是HTML5 Web SQL數據庫中的新成員,我想保存JSON字符串。在HTML5中保存JSON Web SQL數據庫
tx.executeSql("INSERT INTO TA (id, name) VALUES (89,\"{ \"items\":[ { \"order\": 1, \"item_id\": 123123, \"quantity\": 10, \"price\": 1526896, \"total\": 15268960 }, { \"order\": 2, \"item_id\": 113124, \"quantity\": 10, \"price\": 1526896, \"total\": 15268960 }, { \"order\": 3, \"item_id\": 163125, \"quantity\": 10, \"price\": 1626896, \"total\": 16268960 }, { \"order\": 4, \"item_id\": 1723165, \"quantity\": 10, \"price\": 1726896, \"total\": 17268960 }, { \"order\": 5, \"item_id\": 183190, \"quantity\": 10, \"price\": 1826896, \"total\": 18268960 } ], \"other\":[ { \"order\": 1, \"item\": 123123, \"price\": 10 }, { \"order\": 2, \"item\": 123123, \"price\": 10 } ,{ \"order\": 3, \"item\": 123123, \"price\": 10 } ] }\")";
但它不接受引號的值。
我測試這個樣本
tx.executeSql("INSERT INTO TA (id, name) VALUES (90,\"a\")");
而且
tx.executeSql("INSERT INTO TA (id, name) VALUES (90,\"\"a\"\")");
並獲得相同的結果。
什麼錯誤消息? –
不要將JSON字符串直接放入查詢中。改爲使用佔位符和參數:http://stackoverflow.com/a/23434271/1233508 – DCoder
@Karl Richter HTML5 Web SQL數據庫永遠不會打印日誌或錯誤 – user2326448