C/C++ JSON 解析器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36471581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C/C++ JSON parser
提问by user2329702
We have requirement of C/C++ Parser in my application. What application does is it calls rest webservice and takes output from service. If output is JSON , it should parse it and shows the result to end user.
我们在我的应用程序中需要 C/C++ 解析器。应用程序所做的是调用 rest webservice 并从服务中获取输出。如果输出是 JSON ,它应该解析它并向最终用户显示结果。
Could you please recommend me good/best C/CPP JSON parser (according to you) so that I can use in my application?
您能否向我推荐好的/最好的 C/CPP JSON 解析器(根据您的说法),以便我可以在我的应用程序中使用?
When I search online, I am getting multiple JSON parsers. But I would like to know about the best.
当我在线搜索时,我得到了多个 JSON 解析器。但我想知道最好的。
Thanks in advance
提前致谢
回答by russw_uk
Assuming you're happy with a C++ implementation of the parser, I've not had any issues with nlohmann/json; although there are faster libraries it has been fast enough for my requirements and has the advantages that:
假设您对解析器的 C++ 实现感到满意,我对nlohmann/json没有任何问题;尽管有更快的库,但它已经足以满足我的要求,并且具有以下优点:
- It is very easy to integrate into your project (single header)
- A clean and simple API without excessively verbose syntax
- Good test coverage
- 很容易集成到您的项目中(单个标题)
- 一个干净简单的 API,没有过于冗长的语法
- 良好的测试覆盖率
The Github page linked above has a great overview so it's not worth me going into much more detail here.
上面链接的 Github 页面有一个很好的概述,所以我不值得在这里详细介绍。
For a comparison of libraries along multiple facets (not just performance) you could look here: miloyip/nativejson-benchmark
要从多个方面(不仅仅是性能)比较库,您可以在这里查看:miloyip/nativejson-benchmark
回答by KimKulling
We are happy with RapidJson, which is in use for AssetImporterLib for the GLTF-importer.
我们对RapidJson感到满意,它用于 GLTF 导入器的 AssetImporterLib。
You can find a performance test here( 100% is best ). Regarding to these examples RapiJson has won. Be never measured the performance on our own to this lib in special.
您可以在此处找到性能测试(100% 最好)。关于这些例子,RapiJson 赢了。从来没有专门测量过我们自己对这个库的性能。