-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Row to serde_json::Value #174
Comments
You can convert them into Vec/Map and then to Value. |
Not really understanding, any code snippet? |
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 |
But the problem is the row structure is unknown. I need to use ColSpec to get correct type |
Is there anything preventing you from calling |
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 |
|
Yes, currently using this, but not sure how to deal with nested map and triple |
The same way you'd do it with other programming languages - recursion. |
@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!(),
}; |
You are asking a basic programming question now, which is out of scope of rust crates. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
is anyone have idea how to convert the Map/List to serde_json::Value? assume the struct is unknown.
The text was updated successfully, but these errors were encountered: