You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnmain(){let json = vec![b'"', 128, b' ', b' ', b' ', b'"'];let e = serde_json::from_slice::<String>(&json).unwrap_err();println!("serde_json error: {e}");let e = std::str::from_utf8(&json).unwrap_err();println!("from_utf error: {e}");}
outputs:
serde_json error: invalid unicode code point at line 1 column 6
from_utf error: invalid utf-8 sequence of 1 bytes from index 1
serde_json claims the error position was a the end of the JSON string, not where it actually was. If you insert more spaces, the error always comes at the next ".
In comparison, if the error is caused by a control character, the position is correct:
fnmain(){// let json = vec![b'"', 128, b' ', b' ', b' ', b'"'];let json = vec![b'"', b'\t', b' ', b' ', b' ', b'"'];let e = serde_json::from_slice::<String>(&json).unwrap_err();println!("serde_json error: {e}");}
outputs:
serde_json error: control character (\u0000-\u001F) found while parsing a string at line 1 column 2
I'm using serde_json version 1.0.87.
The text was updated successfully, but these errors were encountered:
The following
outputs:
serde_json
claims the error position was a the end of the JSON string, not where it actually was. If you insert more spaces, the error always comes at the next"
.In comparison, if the error is caused by a control character, the position is correct:
outputs:
I'm using
serde_json
version 1.0.87.The text was updated successfully, but these errors were encountered: