C语言的 JSON 解析包 libjson
openkk
13年前
<p>libjson 是一个完全兼容 JSON 规范的 json 格式数据的 C 语言解析包。</p> <p>以下是libjson:</p> <ul> <li>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.</li> <li>No object model integrated: easy integration with any model by the means of a simple callback.</li> <li>Small codebase: handcoded parser and efficient factorisation make the code smalls.</li> <li>Fast: use efficient code, and small parsing tables to not do any extra work and remains as fast and efficient as possible.</li> <li>Full JSON support: tested through a small and precise testsuite.</li> <li>No native conversion: callback only string of data and leave the actual representation of data to the caller</li> <li>Supports putting limits on nesting level. security against DoS over very deep data.</li> <li>Supports putting limits on data (string/int/float) size. security against DoS over very large data object.</li> <li>Optionally support YAML/python comments and C comments.</li> <li>Supports projects-specific allocation functions to integrate completely with projects</li> <li>jsonlint utility provided with the library to verify, or reformat json stream. also useful as example on how to use the library.</li> </ul> <p>示例代码:</p> <pre class="brush:cpp; toolbar: true; auto-links: false;">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; }</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324129739046" target="_blank">http://www.open-open.com/lib/view/home/1324129739046</a></p> <p></p>