初学C++ 使用json对象----------rapidjson
2016-11-28 22:14
369 查看
RapidJSON是一个只有头文件的C++ JSON库,只需要拷贝“include/rapidjson”目录到工程包含路径下即可使用。
rapidjson库下载网地址:https://github.com/miloyip/rapidjson
rapidjson优点:
1.简单,易操作,RapidJSON只用包含起头文件即可使用;
2.更重要的是避免的采用jsoncpp生成静态链接库后,若要调用webservice会与clr产生的错误:
“/MTd”和“/clr”命令行选项不兼容
RapidJSON的使用
1.解压文件后,拷贝include\rapidjson文件夹到项目路径下。
2.引入rapidjson库头文件
3、使用
ps:尚未验证以下内容
RapidJSON项目的构建需要使用一个工具,就是premake
premake下载地址:http://industriousone.com/premake/download
rapidjson库下载网地址:https://github.com/miloyip/rapidjson
rapidjson优点:
1.简单,易操作,RapidJSON只用包含起头文件即可使用;
2.更重要的是避免的采用jsoncpp生成静态链接库后,若要调用webservice会与clr产生的错误:
“/MTd”和“/clr”命令行选项不兼容
RapidJSON的使用
1.解压文件后,拷贝include\rapidjson文件夹到项目路径下。
2.引入rapidjson库头文件
#include "rapidjson/rapidjson.h" #include "rapidjson/document.h" #include "rapidjson/reader.h" #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" using namespace rapidjson;//这个可能要手动输入,小助手可能看不到这个
3、使用
const char* str = "{\"filename\":\"wenjianming\",\"number\":22,\"result\":\"1\",\"a\":{\"b\":1}}";//注意这个格式,\"是转义" Document doc; // 在DOM中解析json字符串 doc.Parse(str); // 读取json数据 const Value& filename= doc["filename"]; const char* s=filename.getString();
ps:尚未验证以下内容
RapidJSON项目的构建需要使用一个工具,就是premake
premake下载地址:http://industriousone.com/premake/download
相关文章推荐
- 初学c++使用json----jsoncpp
- 使用typeid和RTTI C++获取对象运行时类名称
- 使用NewtonSoft.JSON.dll来序列化和发序列化对象
- 使用JSON做Ajax解析服务端返回的JSON对象方法
- C++箴言:使用对象管理资源
- 使用Java操作JSON字符串对象
- C++中函数对象的使用
- IE8如何使用原生JSON对象? 推荐
- 使用Java操作JSON字符串对象
- 使用NewtonSoft.JSON.dll来序列化和发序列化对象
- 在Flex中使用JSON对象为属性赋值
- 使用typeid和RTTI C++获取对象运行时类名称
- 使用JSON-LIB转换JAVA对象
- 使用NewtonSoft.JSON.dll来序列化和发序列化对象
- 使用Yahoo!web服务的json(Javascript对象标识)
- C++对象对内存的使用
- C++对象模型之内存区的使用
- C++对象模型之内存区的使用
- 关于JSON对象,以及联合数组,eval函数的使用参考
- c++游戏开发中使用json