We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I receive this JSON over the wire: [1,[2556,2.06,2559.5,4.8,18.4,0.0073,2556,22039.67029419,2640,2450.1]]
[1,[2556,2.06,2559.5,4.8,18.4,0.0073,2556,22039.67029419,2640,2450.1]]
and I would like to decode it into a struct like this:
pub struct Example { value_one: 1 value_two: 2556 value_three: 2.06 ... }
Does serde-rs implement this out of the box? Please note that none of the values in the array come with a key. I only have the values.
The text was updated successfully, but these errors were encountered:
Decoding JSON arrays into a struct is supported out of the box. You will need to combine them if you want two arrays to deserialize into one struct.
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; #[derive(Deserialize, Debug)] struct Outer { value_one: u64, inner: Inner, } #[derive(Deserialize, Debug)] struct Inner { value_two: u64, value_three: f64, value_four: f64, value_five: f64, value_six: f64, value_seven: f64, value_eight: u64, value_nine: f64, value_ten: u64, value_eleven: f64, } fn main() { let j = "[1,[2556,2.06,2559.5,4.8,18.4,0.0073,2556,22039.67029419,2640,2450.1]]"; let s: Outer = serde_json::from_str(j).unwrap(); println!("{:#?}", s); }
Sorry, something went wrong.
No branches or pull requests
Hi,
I receive this JSON over the wire:
[1,[2556,2.06,2559.5,4.8,18.4,0.0073,2556,22039.67029419,2640,2450.1]]
and I would like to decode it into a struct like this:
Does serde-rs implement this out of the box? Please note that none of the values in the array come with a key. I only have the values.
The text was updated successfully, but these errors were encountered: