rust-embedded-community/serde-json-core

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error("EOF while parsing a value", line: 1, column: 0)'

kematy opened this issue · 2 comments

thread '' panicked at 'called Result::unwrap() on an Err value: Error("EOF while parsing a value", line: 1, column: 0)', src\lib.rs:124:23

line 124:
let json_obj: Value=serde_json::from_str(s.as_str()).unwrap();

@kematy That is intended behaviour?

There are a number of issues here, most important one being that you are using serde_json, rather than serde_json_core (different crate, https://github.com/serde-rs/json)

You are calling unwrap() on an error type, causing a panic.

The reason it returns an error, seems to be that you are attempting to parse invalid JSON, though this is just a guess without knowing the contents of s.as_str()

Closing this with reference to above comment about it being a user error.

Feel free to re-open if this is still an issue.