Redis: the trait `FromRedisValue` is not implemented for `redis_macros::Json<_>`

I used to have redis crate: 0.23 and this snippet worked:

static REDIS_CLIENT: Lazy<Client> =
    Lazy::new(|| Client::open("redis://xxx:1234").expect("Failed to connect to redis"));

pub async fn get_json(key: &str) -> RedisResult<Value> {
    let mut conn = REDIS_CLIENT.get_tokio_connection().await?;
    let Json(json_data) = conn.json_get(key, "$").await?;


Now with 0.24, I changed nothing, getting this error:

error[E0277]: the trait bound `redis_macros::Json<_>: FromRedisValue` is not satisfied
   --> src/
14  |     let Json(json_data) = conn.json_get(key, "$").await?;
    |                                ^^^^^^^^ the trait `FromRedisValue` is not implemented for `redis_macros::Json<_>`
    = help: the following other types implement trait `FromRedisValue`:
            and 44 others
note: required by a bound in `redis::JsonAsyncCommands::json_get`
   --> /home/ubuntu/.cargo/registry/src/
177 | / implement_json_commands! {
178 | |     'a
179 | |     
180 | |     /// Append the JSON `value` to the array at `path` after the last element in it.
...   |
298 | |     fn json_get<K: ToRedisArgs, P: ToRedisArgs>(key: K, path: P) {
    | |        -------- required by a bound in this associated function
...   |
388 | |     }
389 | | }
    | |_^ required by this bound in `JsonAsyncCommands::json_get`
    = note: this error originates in the macro `implement_json_commands` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.

What changed?

Extra question, what's best practice to reuse Redis connection?

Seems like you need to disambiguate the deserialization target type. You can use the turbofish syntax for it

For a multithreaded environment you usually use an Arc to share a resource. I'm not sure if the Redis connection is already wrapped in an Arc for your convenience.

how to do that turbofish in my case?

Like this:


Doesn't seem to help, same issue

The return value is the third generic parameter, so it should be something like this:

conn.json_get::<_, _, YourTargetType>(key

The type is serde_json, getting this error now:

error[E0277]: the trait bound `serde_json::Value: FromRedisValue` is not satisfied
   --> src/
14  |     let json_data: Value = conn.json_get::<_, _, Value>(key, "$").await?;
    |                                 ^^^^^^^^ the trait `FromRedisValue` is not implemented for `serde_json::Value`

I can't find any implementation of FromRedisValue for serde_json::Value. Are you sure that this worked before?

Yes, it been working until 0.24:

Randomly guessing, but maybe your dependency in Cargo.toml is missing the JSON feature?

redis = { version = "0.24.0", features = ["json"] }

No, I have the feature enabled