Closed mzfr closed 3 years ago
@mzfr , I think Value
should come from serde_json crate. See https://docs.serde.rs/serde_json/value/enum.Value.html.
Yes I tried that as well
fn general_package_info(jsondata: serde_json::Value) {}
But with this I get the following error:
|
38 | general_package_info(jsondata);
| ^^^^^^^^ expected enum `Value`, found enum `Result`
|
= note: expected enum `Value`
found enum `Result<Value, minidom::error::Error>`
ok, I fixed that. Didn't had to include anything else in the cargo. Just had to unwrap it.
In the end the thing that worked for me was:
let text = std::fs::read_to_string(xmlpath).unwrap();
let conf = Config::new_with_defaults();
let json = xml_string_to_json(text.to_owned(), &conf);
another_function(json.unwrap())
And in the another_function
we can accept serde_json::Value
fn another_function(jsondata: serde_json::Value)
I am new to rust so just wanted to ask:
This is how I read and changed the XML to json. And not I want to send the
json
value to another function.Now when I make a new function like
fn parser(jsondata: serde::Value)
I get error sayingcannot find type Value in crate serde
. But the doc ofquickxml_to_serde
says it changesxml
toserde::Value
.Can you please tell me what will be the right type for this?