项目作者: zTgx

项目描述 :
json-checker is a wrapper around JSON-c.
高级语言: Rust
项目地址: git://github.com/zTgx/json-checker.git
创建时间: 2019-08-21T16:51:05Z
项目社区:https://github.com/zTgx/json-checker

开源协议:Other

下载


json-checker Build Status crate

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

Usage

Add dependencies

  1. [dependencies]
  2. json-checker = "0.1.0"
  1. extern crate json_checker;
  2. use json_checker::*;
  3. extern crate ncurses;
  4. use ncurses::*;
  5. fn main() {
  6. let mut checker = JsonChecker::new(20);
  7. initscr();
  8. raw();
  9. keypad(stdscr(), true);
  10. printw("Enter a json string: ");
  11. loop {
  12. let next_char = getch();
  13. if next_char == 0xa {
  14. endwin();
  15. break;
  16. }
  17. if checker.check_char(next_char) == 0 {
  18. endwin();
  19. panic!("JSON_checker_end: syntax error\n");
  20. }
  21. }
  22. if checker.done() == 0 {
  23. panic!("JSON_checker_end: syntax error\n");
  24. } else {
  25. println!("well-formed JSON text!")
  26. }
  27. }