-
Notifications
You must be signed in to change notification settings - Fork 35
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
Function to convert serde_json::Value or serde_yaml::Value into regorus::Value #195
Comments
Would serde_json::from_value and serde_yaml::from_value be sufficient? use serde_json::json;
fn main() {
let j:serde_json::Value = json!({
"fingerprint": "0xF9BA143B95FF6D82",
"location": "Menlo Park, CA",
"Hello": [
1,
"Foo"
]
});
println!("{j:#?}");
let yaml = "
- 1
- [0, 0, 0]
- {x: 1.0, y: 2.0}
";
let k : serde_yaml::Value = serde_yaml::from_str(&yaml).unwrap();
println!("{k:#?}");
// Convert serde_json::Value to regorus::Value, consuming it.
let u: regorus::Value = serde_json::from_value(j).unwrap();
println!("{u:#?}");
// Convert serde_yaml::Value to regorus::Value, consuming it.
let v: regorus::Value = serde_yaml::from_value(k).unwrap();
println!("{v:#?}");
} |
Sorry, and shame on me, I forgot the basics... |
No worries. I'm thinking of adding a |
That will make things straightforward |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This type of conversion will likely be very common. I don't think it's possible, with the current
regorus
API, to useserde-transcode
(or a similar approach) to perform this conversion efficiently. It might be helpful to add a method to perform this type of transformation.The text was updated successfully, but these errors were encountered: