允许字符串数组的C++JSON编写器
C++ JSON writer that allows array of strings
我需要一个C++库(或头,或代码片段),它将允许我编写包含字符串数组的JSON,例如一堆错误消息。
据我所知,Boost的属性树不允许字符串数组,尽管我在项目的另一部分使用Boost。
理想情况下,JSON可以发送到stdout,但如果必须将其写入文件,我可以接受它。
有什么想法我可以用吗?
我喜欢http://jsoncpp.sourceforge.net/
Json::Value fromScratch;
Json::Value array; // this is the array of strings
array.append("hello");
array.append("world");
fromScratch["hello"] = "world";
fromScratch["number"] = 2;
fromScratch["array"] = array;
fromScratch["object"]["hello"] = "world";
// write in a nice readible way
Json::StyledWriter styledWriter;
std::cout << styledWriter.write(fromScratch);
示例取自http://www.thomaswhitton.com/blog/2013/06/27/json-c-plus-plus-examples/
相关文章:
- 如何在 c++ 非托管代码中反序列化 byte[] 的 json 字符串?
- 使用 minijson-reader 库读取 JSON 字符串时出现问题
- POCO C++对象到 JSON 字符串序列化
- 将可变参数模板参数转换为 JSON 字符串
- 从 json 字符串将 QVariant 转换为 QList<MyClass>
- 如何使用 boost 属性树来解析 boost 中 json 字符串中的数组中的元素?
- 使用Python将C 结构更改为JSON字符串
- 如何将变量用作原始 JSON 字符串中的数据?
- 如何将 JsonObject 转换为 JSON 字符串
- 从.txt文件中将C 中的JSON字符串贴上
- 使用 Cereal 反序列化 JSON 字符串
- 使用 jsoncpp 解析 JSON 字符串
- Rapidjson漂亮的打印使用JSON字符串作为作者的输入
- 如何处理JSON字符串中的unicode值
- 为什么BOOST创建的JSON字符串与我的服务器所需的不同
- 如何在C++中使用boost库将类对象转换为json字符串
- 如何在使用JSON boost序列化创建JSON字符串时获取名称-值对
- 如何在网络上序列化并发送JSOn字符串中的std::list
- 将带有 json 字符串的帖子发送到服务器
- 使用 Casablanca REST SDK 将 JSON 字符串转换为C++对象