- 论坛徽章:
- 1
|
#include <stdlib.h>
#include <stdio.h>
#include "JSON_checker.h"
int main(int argc, char* argv[]) {
/*
Read STDIN. Exit with a message if the input is not well-formed JSON text.
jc will contain a JSON_checker with a maximum depth of 20.
*/
JSON_checker jc = new_JSON_checker(20);
for (; {
int next_char = getchar();
if (next_char <= 0) {
break;
}
if (!JSON_checker_char(jc, next_char)) {
fprintf(stderr, "JSON_checker_char: syntax error\n" ;
exit(1);
}
}
if (!JSON_checker_done(jc)) {
fprintf(stderr, "JSON_checker_end: syntax error\n" ;
exit(1);
}
}
这个是一个个的判断
假如我有一个字符串需要判读是否为json格式({"id":"12791825930203","time":1279182593,"war_obg_id":4522,"a_captain":0,"d_captain":0})要判断怎么办
char* str='{"id":"12791825930203","time":1279182593,"war_obg_id":4522,"a_captain":0,"d_captain":0}';
我如何判断呢? |
|