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

Illegal JSON does not return correct Error value #10

Open
Oyami-Srk opened this issue Jul 30, 2024 · 0 comments
Open

Illegal JSON does not return correct Error value #10

Oyami-Srk opened this issue Jul 30, 2024 · 0 comments

Comments

@Oyami-Srk
Copy link

Illegal JSON like 1@ will be normally parsed into Number(1) instead of returning an Error.

This behavior is different from the regular serde_json crate.

Test code:

use serde::Deserialize;
use serde_json::Value;

fn main() {
    let json = "1@";
    let data = json.as_bytes();
    let v = serde_json::from_slice::<Value>(data);
    println!("serde-json: {:?}", v);

    let mut deserializer = serde_json::Deserializer::from_slice(data);
    deserializer.disable_recursion_limit();
    let deserializer = serde_stacker::Deserializer::new(&mut deserializer);
    let v = Value::deserialize(deserializer);
    println!("serde-stacker: {:?}", v);
}

Output:

serde-json: Err(Error("trailing characters", line: 1, column: 2))
serde-stacker: Ok(Number(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant