https://github.com/ztgx/json-checker
json-checker is a wrapper around JSON-c.
https://github.com/ztgx/json-checker
c checker ffi json rust
Last synced: 3 months ago
JSON representation
json-checker is a wrapper around JSON-c.
- Host: GitHub
- URL: https://github.com/ztgx/json-checker
- Owner: zTgx
- License: apache-2.0
- Created: 2019-08-21T16:51:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-21T17:20:33.000Z (almost 7 years ago)
- Last Synced: 2025-08-05T09:39:12.303Z (11 months ago)
- Topics: c, checker, ffi, json, rust
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# [json-checker](https://github.com/zTgx/json-checker.git) [](https://travis-ci.org/zTgx/json-checker) [](https://crates.io/crates/json-checker)
A wrapper around [JSON-c](https://github.com/douglascrockford/JSON-c.git), a light-weight json checker by Douglas Crockford .
# Usage
Add dependencies
```
[dependencies]
json-checker = "0.1.0"
```
```rust
extern crate json_checker;
use json_checker::*;
extern crate ncurses;
use ncurses::*;
fn main() {
let mut checker = JsonChecker::new(20);
initscr();
raw();
keypad(stdscr(), true);
printw("Enter a json string: ");
loop {
let next_char = getch();
if next_char == 0xa {
endwin();
break;
}
if checker.check_char(next_char) == 0 {
endwin();
panic!("JSON_checker_end: syntax error\n");
}
}
if checker.done() == 0 {
panic!("JSON_checker_end: syntax error\n");
} else {
println!("well-formed JSON text!")
}
}
```