pub struct Problem { /* private fields */ }Expand description
One problem in a file: what is wrong, where, and how much it matters.
Implementations§
Source§impl Problem
impl Problem
Sourcepub fn offset(&self) -> usize
pub fn offset(&self) -> usize
The byte offset in the text where the problem is. Always on a character boundary.
Sourcepub fn severity(&self) -> Severity
pub fn severity(&self) -> Severity
The problem’s severity under the config it was checked with. Never Off.
A second place the problem refers to: the first occurrence of a duplicate key, or where an unterminated string or comment starts.
Sourcepub fn path(&self) -> Option<&str>
pub fn path(&self) -> Option<&str>
The JSONPath of a duplicate key, such as $.server.port, or None for other problems.
A path longer than 256 bytes keeps its ends, with … in place of the middle, so a path is
at most 259 bytes: 256 and the three of ….
use jsonvet::{check, Config, Dialect};
let report = check(r#"{"server": {"port": 80, "port": 8080}}"#, &Config::new(Dialect::Json));
assert_eq!(report.problems()[0].path(), Some("$.server.port"));
assert_eq!(check("[1 2]", &Config::new(Dialect::Json)).problems()[0].path(), None);👎Deprecated since 3.0.0: use related().map(|r| r.offset)
use related().map(|r| r.offset)
The offset of related.
Trait Implementations§
impl Eq for Problem
impl StructuralPartialEq for Problem
Auto Trait Implementations§
impl Freeze for Problem
impl RefUnwindSafe for Problem
impl Send for Problem
impl Sync for Problem
impl Unpin for Problem
impl UnsafeUnpin for Problem
impl UnwindSafe for Problem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more