-1
pub fn rust_server() -> redis::RedisResult<()> {
    println!("-> redis_server");
    let client = redis::Client::open(get_uri())?;
    let mut con = client.get_connection()?;

    println!("-> redis_server: {}", get_uri());

    println!("-> redis_server_pub_sub");
    let mut pub_sub = con.as_pubsub();

    println!("-> redis_server subscribe channels: {}", get_sub());
    pub_sub.subscribe(get_sub())?;

    loop {
        let msg = pub_sub.get_message()?;
        let payload: String = msg.get_payload()?;

        println!("{}", payload);
    }
}

如何解析以下类型的JSON有效负载?Stringserde_json

let payload: String = msg.get_payload()?;
4

1 回答 1

1

serde_json文档解释了如何以无类型和强类型的方式JSON从 a 获取数据:String

于 2020-07-02T15:49:56.607 回答