fionn_gron/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! # fionn-gron - SIMD-accelerated gron implementation
3//!
4//! This module provides a high-performance implementation of the gron transformation,
5//! which converts JSON into greppable, line-oriented output format.
6//!
7//! ## Features
8//!
9//! - **SIMD-accelerated parsing**: Uses fionn's tape for efficient JSON parsing
10//! - **Efficient path building**: Stack-based incremental path construction
11//! - **Extended path syntax**: Supports bracket notation for special field names
12//! - **Ungron support**: Reconstruct JSON from gron output
13//! - **JSONL support**: Process newline-delimited JSON files
14//! - **Query mode**: Filter output with JSONPath-like queries
15//!
16//! ## Example
17//!
18//! ```rust,ignore
19//! use fionn::gron::{gron, GronOptions};
20//!
21//! let json = r#"{"name": "Alice", "age": 30}"#;
22//! let output = gron(json, &GronOptions::default())?;
23//! // Output:
24//! // json = {};
25//! // json.name = "Alice";
26//! // json.age = 30;
27//! ```
28//!
29//! ## JSONL Processing
30//!
31//! ```rust,ignore
32//! use fionn::gron::{gron_jsonl, GronJsonlOptions};
33//!
34//! let jsonl = b"{\"a\":1}\n{\"b\":2}";
35//! let output = gron_jsonl(jsonl, &GronJsonlOptions::default())?;
36//! // json[0].a = 1;
37//! // json[1].b = 2;
38//! ```
39//!
40//! ## Query Mode
41//!
42//! ```rust,ignore
43//! use fionn::gron::{gron_query, Query, GronOptions};
44//!
45//! let json = r#"{"users": [{"name": "Alice"}, {"name": "Bob"}]}"#;
46//! let query = Query::parse(".users[*].name")?;
47//! let output = gron_query(json, &query, &GronOptions::default())?;
48//! // json.users[0].name = "Alice";
49//! // json.users[1].name = "Bob";
50//! ```
51
52mod gron_core;
53mod gron_jsonl;
54mod gron_parallel;
55mod gron_query;
56mod gron_zerocopy;
57mod path_builder;
58mod path_extended;
59mod query;
60mod simd_escape;
61mod simd_unescape;
62mod simd_utils;
63mod ungron;
64
65pub use gron_core::{GronOptions, GronOutput, gron, gron_to_writer};
66pub use gron_jsonl::{
67    ErrorMode, GronJsonlOptions, IndexFormat, JsonlStats, gron_jsonl, gron_jsonl_streaming,
68    gron_jsonl_to_writer,
69};
70pub use gron_parallel::{GronParallelOptions, gron_parallel};
71pub use gron_query::{GronQueryOptions, gron_query, gron_query_to_writer};
72pub use gron_zerocopy::{GronLine, GronOutput as GronOutputZc, gron_zerocopy};
73pub use path_builder::PathBuilder;
74pub use path_extended::{
75    ExtendedPathComponent, ParsedExtendedPath, parse_extended_path, parse_extended_path_ref,
76};
77pub use query::{MatchPotential, Query, QueryError, QuerySegment};
78pub use simd_escape::{escape_json_string_simd, escape_json_to_string};
79pub use simd_unescape::{UnescapeError, unescape_json_string_simd, unescape_json_to_string};
80pub use simd_utils::{escape_json_string, needs_escape, needs_quoting};
81pub use ungron::{ungron, ungron_to_value};