2 releases
Uses new Rust 2024
new 0.0.2 | Apr 13, 2025 |
---|---|
0.0.1 | Apr 13, 2025 |
#1108 in Parser implementations
27KB
723 lines
package_json_parser
A Rust library for parsing and validating package.json files.
Features
- Parse package.json files with strong type safety
- Validate package.json fields according to npm specifications
- Error handling with detailed error messages
- Efficient parsing with optimized dependencies
Installation
Add this to your Cargo.toml
:
[dependencies]
package_json_parser = "0.0.1"
Usage
use package_json_parser::PackageJson;
fn main() {
let json_str = r#"
{
"name": "my-package",
"version": "1.0.0",
"dependencies": {
"some-package": "^1.0.0"
}
}
"#;
match PackageJson::from_str(json_str) {
Ok(package) => {
println!("Package name: {}", package.name);
println!("Version: {}", package.version);
}
Err(e) => println!("Error parsing package.json: {}", e),
}
}
Documentation
For detailed documentation, please visit docs.rs.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Dependencies
~4.5–7MB
~124K SLoC