JSON serialization fails on structs with one field
KongouDesu opened this issue · comments
Attempting to serialize a struct with a single field results in an empty JSON object:
use nanoserde::{SerJson}; // v0.1.17
#[derive(SerJson)]
struct Broken {
field: f32,
}
#[derive(SerJson)]
struct Works {
field1: f32,
field2: f32,
}
fn main() {
let b = Broken {
field: 0.1,
};
let w = Works {
field1: 0.2,
field2: 0.3,
};
println!("{}",b.serialize_json()); // Fails
println!("{}",w.serialize_json()); // Succeeds
}
Compiling emits "warning: field is never read: field
" on 'Broken'
Running prints
{}
{"field1":0.2,"field2":0.3}
Thanks for the report!
Should be fixed in 0.1.18