How to get the serde_json::Value wrapped in postgres_types::Json

I have a Postgres table with a column params in JSON type. I can query the row using tokio-postgres but cannot get the inner value to alter it.

The doc and src are at

Sample code is as following:

let (client, conn) = tokio_postgres::connect("CONNECTION_STRING", NoTls).await?;
// ....   

let rows = &client.query("SELECT params FROM Accounts where id=$1;", &[&account_id]).await?;
if rows.len() > 0 {
    let params = rows[0].try_get::<&str, postgres_types::Json<serde_json::Value>>("params")?;
    // Question: params has type `postgres_types::Json<serde_json::Value>`, but I want it to be `serde_json::Value`. I check the document but cannot find out how to get it.

Thanks in advance.

Nevermind, I got how to make it work

It should just be rewritten like this:
let params = rows[0].try_get::<&str, serde_json::Value>("params")?;

Thread closed.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.