UseJsonFormat
Whether to submit and return the JSON encoding for CQL data types.
Data Type
bool
Default Value
true
Remarks
Cassandra 2.2 introduced a CQL extension that allows you to JSON-encode CQL data types. By default, you use the JSON syntax to manipulate data and SELECT statements return JSON through the connector. Set this property to false to use CQL literals to interact with Cassandra data.
The syntax for CQL literals has several differences from JSON. For example:
- CQL strings are defined in single quotes, while JSON strings are defined in double quotes.
- CQL sets, tuples, and lists are JSON-encoded as arrays.
- User-defined types and CQL uuid types are JSON-encoded as objects.
Format | Syntax | ||
CQL | INSERT INTO users (user_id, emails) VALUES (@user_id, @emails) | ||
Parameters | |||
user_id | frodo | ||
emails | {'[email protected]', '[email protected]'} | ||
JSON | INSERT INTO users (user_id, emails) VALUES (@user_id, @emails) | ||
Parameters | |||
user_id | frodo | ||
emails | ["[email protected]", "[email protected]"]) |
Note that in queries to the connector, you must use single quotes to define strings.