Skip to main content

find_value

Function find_value 

Source
pub fn find_value<'a>(
    json: &'a [u8],
    path: &[PathSegment<'_>],
) -> Result<&'a [u8], Error>
Expand description

Locates a JSON value byte-slice within a raw JSON buffer by its path.

Returns the slice of the raw JSON value (e.g., b"123", b"\"hello\"", or b"{\"nested\": true}").

§Examples

use jshift::{find_value, parse_path};

let json = b"{\"metadata\": {\"author\": \"farmer\"}}";
let val = find_value(json, &parse_path("metadata.author")).unwrap();
assert_eq!(val, b"\"farmer\"");