卡桑德拉插入 JSON 字符 ' 错误



我正试图在cassandra中插入一些json格式的值,但由于字符撇号(')是限制json字符串的字符,我无法插入"I'm"或"let's go"等短语

你知道使用json格式插入这种消息的替代方案吗?

声明:

INSERT INTO TweetsTest JSON '{"IsFavorited":false,"ProfileLocation":"Paris, TX","IsPossiblySensitive":false,"User":"abela_here","Message":"biebahpurpose: https://t.co/e5csn7ZNrl RT halsey: **Let's** go. #TheFeeling justinbieber Skrillex","CreatedAt":"Wed Oct 28 00:33:22 CST 2015","IsRetweet":false,"IsRetweeted":false,"IsTruncated":false,"QuotedStatusId":-1,"RetweetCount":0,"InReplyToScreenName":null,"Source":"<a href="http://ifttt.com" rel="nofollow">IFTTT</a>","InReplyToUserId":-1,"UserId":3301301628,"Id":659256625686016000,"CurrentUserRetweetId":-1,"HashtagEntities":"TheFeeling"}';

错误:

第1行字符204处的语法无效INSERT INTO TweetsTest JSON'{"IsFavorited":false,"ProfileLocation":"Paris,TX","IsPossiblySensitive":false、"User":"abela_here"、"Message":"biebaharive:https://t.co/e5csn7ZNrl哈尔西:我们走吧#TheFeeling justinbieber Skrillex","CreatedAt":"Wed Oct 28 00:33:22 CST 2015","IsRetweet":false,"IsRetweeted":false、"IsTruncated":false、"QuotedStatusId":-1、"RetweetCount":0、"InReplyToScreenName":null、"Source":"IFTTT<a> ","InReplyToUserId":-1,"UserId":3301301628,"Id":659256625686016000,"CurrentUserRetweetId":-1,"HashtagEntities":"TheFeeling"}';

CQL中的转义符是单引号(')。因此,每当你想插入一个(')时,你需要写两个撇号(')。这与插入JSON时相同。

http://docs.datastax.com/en/cql/3.1/cql/cql_reference/escape_char_r.html

最新更新