1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![forbid(rust_2018_idioms)]
#![deny(unsafe_code, nonstandard_style)]
#![warn(missing_debug_implementations, missing_docs)]

//! # A JSON query language library
//!
//! This crate is used by `jql`, the `JSON query language CLI tool`.

mod apply_filter;
mod array_walker;
mod core;
mod flatten_json_array;
mod get_selection;
mod group_walker;
mod parser;
mod range_selector;
mod truncate;
mod types;
mod utils;

use crate::types::Selection;

use serde_json::Value;

/// Process a Serde JSON Value based on the provided selectors.
///
/// # Example
///
/// ```
/// use serde_json::json;
///
/// let json_array = json!([2, 3, 5, 7, 11]);
///
/// assert_eq!(jql::walker(&json_array, Some("[4]")), Ok(json!(11)));
/// ```
pub fn walker(json: &Value, selectors: Option<&str>) -> Selection {
    core::walker(json, selectors)
}