Cherry Blossom Girl
Cherry Blossom Girl

Reputation: 553

cassandra insert json character ' error

I'm trying to insert some values in json format in cassandra but as the character apostrophe (') is the one for limit json string I cannot insert phrases like "I'm" or "let's go"

do you know an alternative to be able of insert this kind of messages using json format?

Statement:

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"}';

ERROR:

Invalid syntax at line 1, char 204 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":"IFTTT</a>","InReplyToUserId":-1,"UserId":3301301628,"Id":659256625686016000,"CurrentUserRetweetId":-1,"HashtagEntities":"TheFeeling"}';

Upvotes: 0

Views: 1582

Answers (1)

Alec  Collier
Alec Collier

Reputation: 1523

The escape character in CQL is the single quote ('). So you need to write two apostrophe's ('') whenever you want to insert one ('). This is the same when inserting as JSON.

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

Upvotes: 3

Related Questions