項目zip包先放上來,大家可以下載編譯以後運行(gif檔案另存新檔zip即可)。
http://hi.csdn.net/attachment/201107/25/0_1311593791wkYN.gif
libJsonParser是JsonParser的dll項目,原始碼來自json.org網站。
http://fara.cs.uni-potsdam.de/~jsg/json_parser/
testJsonParser是原作者內建的main.c檔案。
int main(int argc, char* argv[]) {int count = 0, result = 0;FILE* input;JSON_config config;struct JSON_parser_struct* jc = NULL;init_JSON_config(&config);config.depth = 19;config.callback = &print;config.allow_comments = 1;config.handle_floats_manually = 0;/* Important! Set locale before parser is created.*/if (argc >= 2) {if (!setlocale(LC_ALL, argv[1])) {fprintf(stderr, "Failed to set locale to '%s'\n", argv[1]);}} else {fprintf(stderr, "No locale provided, C locale is used\n");}jc = new_JSON_parser(&config);input = stdin;for (; input ; ++count) {int next_char = fgetc(input);if (next_char <= 0) {break;}if (!JSON_parser_char(jc, next_char)) {fprintf(stderr, "JSON_parser_char: syntax error, byte %d\n", count);result = 1;goto done;}}if (!JSON_parser_done(jc)) {fprintf(stderr, "JSON_parser_end: syntax error\n");result = 1;goto done;}done:delete_JSON_parser(jc);return result;}
release目錄下有編譯好的dll,和測試命令列。是測試結果: