pub fn pointers<'j>(
input: &'j str,
pointers: &[&str],
bufs: &mut Buffers,
) -> Result<Vec<Option<&'j str>>, ParseError>Expand description
Resolve many pointers in one forward pass, returning raw slices
positionally aligned with pointers (None where a pointer doesn’t
match). Sequential pointer() calls re-scan the document prefix per
query; this walks it once, descending only into members some pointer
still needs and skipping everything else at block speed.
Duplicate keys resolve first-match, like pointer(). The walk stops
as soon as every pointer is resolved.
On valid JSON the result is exactly what resolving each pointer
individually would produce. On malformed documents the batch may
report an error where an individual pointer() call would return
Ok(None): one pass scans every byte some pointer needs, so it can
reach malformed content that a lone query (which aborts at its first
missing key) never would.
let mut bufs = nosj::Buffers::new();
let doc = r#"{"a":1,"b":{"c":2},"d":[3,4]}"#;
let got = nosj::pointers(doc, &["/d/1", "/a", "/x"], &mut bufs).unwrap();
assert_eq!(got, [Some("4"), Some("1"), None]);