json-checker

Crates.iojson-checker
lib.rsjson-checker
version0.1.1
sourcesrc
created_at2019-08-21 17:08:51.636773
updated_at2019-08-21 17:21:07.329149
descriptiona wrapper around JSON-c
homepage
repositoryhttps://github.com/json-checker.git
max_upload_size
id158678
size48,015
(zTgx)

documentation

README

json-checker Build Status crate

A wrapper around JSON-c, a light-weight json checker by Douglas Crockford .

Usage

Add dependencies

[dependencies]
json-checker = "0.1.0"
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!")
    }
}
Commit count: 0

cargo fmt