🚀 JSON KiT
JSON KiT is a high-performance, lightweight Rust utility library engineered for robust JSON data processing.
Its primary mission is to bridge the gap between "JSON with Comments" (JSONC) and standard JSON parsers by efficiently sanitizing input strings. Whether you are dealing with configuration files or human-readable data formats, JSON KiT ensures your data is parse-ready.
📑 Table of Contents
✨ Features
- 🛡️ Comment Stripping: Seamlessly removes standard C-style comments.
- Single-line:
// comment - Multi-line:
/* comment */
- Single-line:
- 🧠 Context-Aware Parsing: Intelligently distinguishes between actual comments and comment-like patterns within string literals (e.g.,
"url": "http://example.com"). - ⚡ High Performance: Built on top of the
regexcrate withOnceLockfor thread-safe, lazy initialization and optimal execution speed.
📦 Installation
Integrate jsonkit into your project by adding it to your Cargo.toml:
[]
= { = "https://gitlab.com/lazylib/rs/jsonkit" }
Note: As this crate is hosted in a private/custom repository, please ensure your git configuration allows access if necessary.
🚀 Usage
Sanitizing JSON content is straightforward. Here is a complete example:
use remove_comment;
Output Preview
📚 API Reference
remove_comment
Transforms a JSON string containing comments into a standard JSON string.
| Parameter | Type | Description |
|---|---|---|
json_with_comments |
&str |
The input string containing JSONC data. |
| Returns | String |
A new, sanitized string ready for parsing. |
🛠️ Development
We welcome contributions! To get started with local development:
-
Clone the repository:
-
Run tests: Ensure all functionality works as expected.
📄 License
This project is proudly licensed under the MIT License. See the LICENSE file for details.
Made with ❤️ in Rust.