亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

SQL對JSON的轉(zhuǎn)義
高洛峰
高洛峰 2016-11-10 17:17:50
0
1
1638

在 R 中執(zhí)行一個SQL,涉及到雙層JSON,也就是第二層的JSON包含一個轉(zhuǎn)義符,\。用R的RMySQL 執(zhí)行的時候第二層的轉(zhuǎn)義符號會被去掉怎么辦。

如果我直接復(fù)制 statement 在SQL中可以執(zhí)行成功。

以下是測試數(shù)據(jù)

 UPDATE ANALYSIS SET POSITION_LIST = '[{\"date\":\"20150512\",\"listDatePosition\":\"[{\\\"code\\\":\\\"600000\\\",\\\"share\\\":274700,\\\"orderType\\\":1,\\\"price\\\":17.32,\\\"todayPosition\\\":0,\\\"totalPosition\\\":43857,\\\"tradeDate\\\":\\\"20150512104300\\\"},{\\\"code\\\":\\\"600652\\\",\\\"share\\\":3900,\\\"orderType\\\":1,\\\"price\\\":18.85,\\\"todayPosition\\\":0,\\\"totalPosition\\\":623,\\\"tradeDate\\\":\\\"20150512104300\\\"},{\\\"code\\\":\\\"600000\\\",\\\"share\\\":180700,\\\"orderType\\\":1,\\\"price\\\":17.32,\\\"todayPosition\\\":0,\\\"totalPosition\\\":43857,\\\"tradeDate\\\":\\\"20150512104300\\\"},{\\\"code\\\":\\\"600652\\\",\\\"share\\\":3900,\\\"orderType\\\":1,\\\"price\\\":18.85,\\\"todayPosition\\\":0,\\\"totalPosition\\\":623,\\\"tradeDate\\\":\\\"20150512104300\\\"}]\",\"startMoney\":8000000,\"counterFee\":0,\"endMoney\":7996494.47,\"deposits\":0,\"totalMarket\":767919.22},{\"date\":\"20150513\",\"listDatePosition\":\"[{\\\"code\\\":\\\"600000\\\",\\\"share\\\":277100,\\\"orderType\\\":1,\\\"price\\\":17.32,\\\"todayPosition\\\":0,\\\"totalPosition\\\":28857,\\\"tradeDate\\\":\\\"20150512104300\\\"},{\\\"code\\\":\\\"600652\\\",\\\"share\\\":3900,\\\"orderType\\\":1,\\\"price\\\":18.85,\\\"todayPosition\\\":0,\\\"totalPosition\\\":623,\\\"tradeDate\\\":\\\"20150512104300\\\"},{\\\"code\\\":\\\"600000\\\",\\\"share\\\":182300,\\\"orderType\\\":1,\\\"price\\\":17.32,\\\"todayPosition\\\":0,\\\"totalPosition\\\":28857,\\\"tradeDate\\\":\\\"20150512104300\\\"},{\\\"code\\\":\\\"600652\\\",\\\"share\\\":3900,\\\"orderType\\\":1,\\\"price\\\":18.85,\\\"todayPosition\\\":0,\\\"totalPosition\\\":623,\\\"tradeDate\\\":\\\"20150512104300\\\"}]\",\"startMoney\":7996494.47,\"counterFee\":0,\"endMoney\":7988530.21,\"deposits\":0,\"totalMarket\":504980.46},{\"date\":\"20150514\",\"listDatePosition\":\"[{\\\"code\\\":\\\"600652\\\",\\\"share\\\":365600,\\\"orderType\\\":1,\\\"price\\\":21.565,\\\"todayPosition\\\":0,\\\"totalPosition\\\":7824,\\\"tradeDate\\\":\\\"20150514103300\\\"}]\",\"startMoney\":7988530.21,\"counterFee\":0,\"endMoney\":7985375.903,\"deposits\":0,\"totalMarket\":171189.12}]',TRADE_DAY_COUNT = '3',DEAL_DETAIL = '[{\"volume\":14649,\"code\":\"600000\",\"price\":17.32,\"tradeType\":1,\"tradetime\":\"20150512104000\"},{\"volume\":9701,\"code\":\"600000\",\"price\":17.32,\"tradeType\":1,\"tradetime\":\"20150512104100\"},{\"volume\":6970,\"code\":\"600000\",\"price\":17.32,\"tradeType\":1,\"tradetime\":\"20150512104200\"},{\"volume\":12537,\"code\":\"600000\",\"price\":17.32,\"tradeType\":1,\"tradetime\":\"20150512104300\"},{\"volume\":623,\"code\":\"600652\",\"price\":18.85,\"tradeType\":1,\"tradetime\":\"20150512104300\"},{\"volume\":15000,\"code\":\"600000\",\"price\":17,\"tradeType\":-1,\"tradetime\":\"20150513103100\"},{\"volume\":19230,\"code\":\"600000\",\"price\":16.9,\"tradeType\":-1,\"tradetime\":\"20150514103100\"},{\"volume\":9627,\"code\":\"600000\",\"price\":16.9,\"tradeType\":-1,\"tradetime\":\"20150514103200\"},{\"volume\":7201,\"code\":\"600652\",\"price\":21.8,\"tradeType\":1,\"tradetime\":\"20150514103300\"}]',TYPE = 2 WHERE ID = UNHEX('8a2362225c3d480489e137dac92e8351')


高洛峰
高洛峰

擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項目經(jīng)理、高級軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...

reply all(1)
三叔

雙層JSON中的\ 在R中是一個轉(zhuǎn)義符號,如果要表達\ 需要用\\表示,所以在生成內(nèi)成的\\需要用 gsub("\"","\\\\\"",json) 來替代。

經(jīng)過這樣處理,才可以保證內(nèi)層的JSON可以順利傳入到MySQL中。


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template