Json解析 – c語言庫libJsonParser

來源:互聯網
上載者:User

項目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,和測試命令列。是測試結果:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.