Canop / deser-hjson

A Serde 1.0 compatible Rust deserializer for Hjson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to deserialize unless there is trailing whitespace

dtolnay opened this issue · comments

In serde-rs/serde-rs.github.io#121 (comment) I was surprised that deser-hjson failed to deserialize i32 from the input 1 -- it took either trailing space or trailing newline for it to succeed.

fn main() {
    println!("{}", deser_hjson::from_str::<i32>("1").unwrap_err());
}
Eof at 1:1 at "1"

Your PR described Hjson as a superset of JSON so I would have expected that to work, as 1 is valid JSON.

Your PR described Hjson as a superset of JSON so I would have expected that to work, as 1 is valid JSON.

It is a bug

I've fixed the bug. I'll push soon with a related test suite checking other similar cases.