treesitter-types-json 1.0.0

Pre-generated strongly-typed AST types for JSON (tree-sitter-json)
Documentation
//! Strongly-typed AST types for JSON, auto-generated from
//! [`tree-sitter-json`](https://docs.rs/tree-sitter-json)'s `node-types.json`.
//!
//! This crate is generated by [`treesitter-types`](https://docs.rs/treesitter-types) and is
//! automatically kept up to date when a new version of the grammar crate is released.
//!
//! These types have been tested by parsing the
//! [SchemaStore](https://github.com/SchemaStore/schemastore) source code.
//!
//! See the [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) project for more
//! information about the underlying parser framework.
//!
//! # Example
//!
//! ```
//! use treesitter_types_json::*;
//!
//! // A small JSON document.
//! let src = b"\
//! {
//!     \"name\": \"hello\",
//!     \"version\": 42
//! }
//! ";
//!
//! // Parse the source with tree-sitter and convert into typed AST.
//! let mut parser = tree_sitter::Parser::new();
//! parser.set_language(&tree_sitter_json::LANGUAGE.into()).unwrap();
//! let tree = parser.parse(src, None).unwrap();
//! let document = Document::from_node(tree.root_node(), src).unwrap();
//!
//! // The document contains one top-level value: a JSON object.
//! assert_eq!(document.children.len(), 1);
//! let Value::Object(object) = &document.children[0] else {
//!     panic!("expected an object");
//! };
//!
//! // The object has two key-value pairs.
//! assert_eq!(object.children.len(), 2);
//!
//! // First pair: "name" => "hello".
//! let first_pair = &object.children[0];
//! assert_eq!(first_pair.key.span.start.row, 1);
//!
//! // Second pair: "version" => 42.
//! let second_pair = &object.children[1];
//! let Value::Number(num) = &second_pair.value else {
//!     panic!("expected a number");
//! };
//! assert_eq!(num.text(), "42");
//! ```

pub use tree_sitter_json;
pub use treesitter_types::tree_sitter;
pub use treesitter_types::{FromNode, LeafNode, ParseError, Span, Spanned};

mod generated;
pub use generated::*;