How to get JSON output
By default zeeSQL returns nested arrays.
zeeSQL can also returns the exact same information as JSON output.
JSON output may be preferable since it is usually easier to parse and all languages offer full support for it.
The ZEESQL.EXEC
and ZEESQL.QUERY
commands support the JSON
flag, which instructs them to return JSON as output.
Examples
The first example is about a command that does not return any rows but only DONE
.
Adding the JSON
flags returns the exact same result but in JSON format.
Another example is when the command returns some rows.
The returned JSON is formatted for saving bytes on the network, not for readability.
However, the result looks like this:
The rows
key contains the actual result set, each row is an object with a key the name of the column and with value the actual value of the row.
Then there is the number_of_rows
key, an integer that describes how many rows are returned in this result set.
The columns
field maps the name of the column to their type.
Overall returning JSON from zeeSQL is very simple, just add the JSON
flag to your command and you are done.
About zeeSQL
zeeSQL is a Redis Module that provides SQL capabilities to Redis. It allows the creation and management of several SQL databases, each one independent from the other. Moreover, zeeSQL provides out-of-the-box secondary indexes capabilities, allowing fast and easy search by value in Redis.
Last updated