Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis command line SET value containing double quotes

Tags:

redis

I want to use redis command line (using redis-cli) to store json values. This is what I do

redis 127.0.0.1:6379> set test '{"a":"b"}' 

This command fails with message :

Invalid argument(s) 

I don't have problem with setting values that don't contain double quotes. What is the correct way to escape double quotes?

like image 486
Viktor K. Avatar asked Jan 11 '14 17:01

Viktor K.


People also ask

How use Redis command line?

To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.

How run multiple commands in Redis command line?

If you want to execute multiple commands, e.g. select # and flushdb, then use ControlAltDel's solution because it won't work using the --pipe option.

What values are enclosed double quotes?

A character literal is always enclosed in double quotes.


1 Answers

Add slashes to quotes

set test "{\"a\":\"b\"}" 
like image 72
Marty Aghajanyan Avatar answered Sep 22 '22 00:09

Marty Aghajanyan