Giter Club home page Giter Club logo

Comments (12)

krojew avatar krojew commented on May 26, 2024

You can convert them into Vec/Map and then to Value.

from cdrs-tokio.

amokio avatar amokio commented on May 26, 2024

You can convert them into Vec/Map and then to Value.

Not really understanding, any code snippet?

from cdrs-tokio.

krojew avatar krojew commented on May 26, 2024

Here's an example how to convert a Cassandra list to a Vec: https://github.com/krojew/cdrs-tokio/blob/master/cdrs-tokio/tests/collection_types.rs#L76
You can do similar thing to a Map.

from cdrs-tokio.

amokio avatar amokio commented on May 26, 2024

Here's an example how to convert a Cassandra list to a Vec: https://github.com/krojew/cdrs-tokio/blob/master/cdrs-tokio/tests/collection_types.rs#L76

You can do similar thing to a Map.

But the problem is the row structure is unknown. I need to use ColSpec to get correct type

from cdrs-tokio.

krojew avatar krojew commented on May 26, 2024

Is there anything preventing you from calling as_r_rust() on the column data?

from cdrs-tokio.

amokio avatar amokio commented on May 26, 2024

Is there anything preventing you from calling as_r_rust() on the column data?

No, but when I declare the new variable like HashMap<String, String (assume I don't know it's String)>, I have to provide type. But assume I don't know the map structure

from cdrs-tokio.

krojew avatar krojew commented on May 26, 2024

ColTypeOptionValue contains the information about the underlying types for collections. You can use that to deserialize appropriate values and move them into serde_json::Value.

from cdrs-tokio.

amokio avatar amokio commented on May 26, 2024

ColTypeOptionValue contains the information about the underlying types for collections. You can use that to deserialize appropriate values and move them into serde_json::Value.

Yes, currently using this, but not sure how to deal with nested map and triple

from cdrs-tokio.

krojew avatar krojew commented on May 26, 2024

The same way you'd do it with other programming languages - recursion.

from cdrs-tokio.

amokio avatar amokio commented on May 26, 2024

@krojew , any idea ?

let v: ColTypeOptionValue = col.clone().col_type.value.expect("");
            let v = match v {
                ColTypeOptionValue::CMap(key, v) => {
                    println!("{:#?} {:#?}", key.id, v);

                    // how to use key.id and v.id here?
                    let map: HashMap<?, ?> = row
                        .r_by_name::<Map>(col.name.as_str())
                        .expect("")
                        .as_r_rust()
                        .expect("");
                }
                _ => todo!(),
            };

from cdrs-tokio.

krojew avatar krojew commented on May 26, 2024

You are asking a basic programming question now, which is out of scope of rust crates.

from cdrs-tokio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.