C語言的 JSON 解析包 libjson
libjson 是一個完全兼容 JSON 規范的 json 格式數據的 C 語言解析包。
以下是libjson:
- Interruptible parser: get the JSON data to the parser any way you want; by appending char by char, or string chunks, the input reading is completely left to the caller.
- No object model integrated: easy integration with any model by the means of a simple callback.
- Small codebase: handcoded parser and efficient factorisation make the code smalls.
- Fast: use efficient code, and small parsing tables to not do any extra work and remains as fast and efficient as possible.
- Full JSON support: tested through a small and precise testsuite.
- No native conversion: callback only string of data and leave the actual representation of data to the caller
- Supports putting limits on nesting level. security against DoS over very deep data.
- Supports putting limits on data (string/int/float) size. security against DoS over very large data object.
- Optionally support YAML/python comments and C comments.
- Supports projects-specific allocation functions to integrate completely with projects
- jsonlint utility provided with the library to verify, or reformat json stream. also useful as example on how to use the library.
示例代碼:
int ret; json_parser parser; ret = json_parser_init(&parser, NULL, my_callback, my_callback_data); if (ret) { fprintf(stderr, "something wrong happened during init\n"); return ret; }
本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!