Skip to content
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

Cannot Deserialize JSON array with empty items to tuple struct #1064

Closed
jans2002 opened this issue Sep 6, 2023 · 0 comments
Closed

Cannot Deserialize JSON array with empty items to tuple struct #1064

jans2002 opened this issue Sep 6, 2023 · 0 comments

Comments

@jans2002
Copy link

jans2002 commented Sep 6, 2023

The following is test code;

use serde::{Serialize,Deserialize};
#[derive(Debug, Deserialize)]
struct Reading(Option<i32>, Option<i32>, Option<i32>, i32,Option<f32>, i32, f32,f64,Option<i32>);

fn main() {
    let data  = "[,,,30,,40,5.5,89.9,]";
    let res: Reading = serde_json::from_str(data).unwrap();
    println!("{:?}", res);
}

It will show

Error("expected value", line: 1, column: 2)

But it should show :

Reading(None, None, None, 30, None, 40, 5.5, 89.9, None)
@jans2002 jans2002 mentioned this issue Sep 6, 2023
@dtolnay dtolnay closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants