Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
m1guelpf committed Jan 17, 2024
0 parents commit 77f5585
Show file tree
Hide file tree
Showing 11 changed files with 1,126 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
name: Rust project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: Swatinem/rust-cache@v2

- name: setup toolchain
uses: hecrj/setup-rust-action@v1
with:
rust-version: stable

- name: cargo test
run: cargo test --all-features

- name: rustfmt
run: cargo fmt --all -- --check

- name: clippy
run: cargo clippy --all --all-features --tests -- -D warnings
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
65 changes: 65 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
license = "MIT"
edition = "2021"
version = "0.1.0"
name = "repair_json"
readme = "README.md"
authors = ["Miguel Piedrafita <[email protected]>"]
repository = "https://github.com/m1guelpf/repair-json"
keywords = ["json", "repair", "incomplete", "streaming"]
description = "Repair incomplete JSON (e.g. from streaming APIs) so it can be parsed as it is received."

[dependencies]
thiserror = "1.0.56"
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) Miguel Piedrafita

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# repair-json

> Repair incomplete JSON (e.g. from streaming APIs or AI models) so it can be parsed as it's received.
[![crates.io](https://img.shields.io/crates/v/repair-json.svg)](https://crates.io/crates/repair-json)
[![download count badge](https://img.shields.io/crates/d/repair-json.svg)](https://crates.io/crates/repair-json)
[![docs.rs](https://img.shields.io/badge/docs-latest-blue.svg)](https://docs.rs/repair-json)

## Usage

```rust
let json_stream = json_source::stream().await?;

while let Some(incomplete_json) = json_stream.next().await {
let valid_json = repair_json::repair(incomplete_json);

// serde_json::from_str(valid_json).unwrap();
}
```

Refer to the [documentation on docs.rs](https://docs.rs/repair-json) for detailed usage instructions.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
8 changes: 8 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tab_spaces = 4
hard_tabs = true
edition = "2021"
use_try_shorthand = true
imports_granularity = "Crate"
use_field_init_shorthand = true
condense_wildcard_suffixes = true
match_block_trailing_comma = true
Loading

0 comments on commit 77f5585

Please sign in to comment.