prettyJson V7.1 使用
头文件
#include "document.h"
#include "prettywriter.h"
#include "filereadstream.h"
#include "filewritestream.h"
#include "stringbuffer.h" using namespace rapidjson;
输出json
std::map<int, POINT> shootMap ;
string strJson;
std::vector<int> everyLoopCount;
string str="abc";
int i=; Document document;
Document::AllocatorType& allocator = document.GetAllocator();
Value root(kObjectType);
Value fixedPoint(kArrayType);//map读取
Value everyLoop(kArrayType);//vector读取 string strX;
string strY;
string strloop;
//map读取,里面存着POINT类型
for (auto iter = shootMap.begin(); iter != shootMap.end(); ++iter)
{
Value arrayBody(kArrayType);
strX = to_string(iter->second.x);
item.SetString(strX.c_str(), strX.size(), allocator);
arrayBody.PushBack(item, allocator);
strY = to_string(iter->second.y);
item.SetString(strY.c_str(), strY.size(), allocator);
arrayBody.PushBack(item, allocator);
fixedPoint.PushBack(arrayBody, allocator);
} //vector 读取,里面存着int类型
for (auto it = everyLoopCount.begin(); it != everyLoopCount.end(); ++it)
{
Value arrayBody(kArrayType);
strloop = to_string(*it);
item.SetString(strloop.c_str(), strloop.size(), allocator);
arrayBody.PushBack(item, allocator);
everyLoop.PushBack(arrayBody, allocator);
}
//map输出
root.AddMember("map", fixedPoint, allocator); //字符串输出
root.AddMember("字符串", StringRef(str.c_str()), allocator); //vector
root.AddMember("vector", everyLoop, allocator); //int
root.AddMember("int", i, allocator); StringBuffer buffer;
Writer<StringBuffer> writer(buffer);
root.Accept(writer);
strJson = buffer.GetString();
读取json
Document doc;
doc.Parse<>(strJson.c_str());
Value & map= doc["map"];
Value & str= doc["字符串"];
Value & vector= doc["vector"];
Value & int= doc["int"];
//输出到map里
POINT targetPoint;
string temp;
int nKey = 0;
if (map.IsArray())
{
for (size_t i = 0; i < map.Size(); ++i)
{
Value & v = map[i];
if (v.IsArray())
{
Value& col = v[0];
temp = col.GetString();
targetPoint.x = atoi(temp.c_str());
col = v[1];
temp = col.GetString();
targetPoint.y = atoi(temp.c_str());
}
rMap.insert(map<int, POINT>::value_type(nKey, targetPoint));
++nKey;
}
}
temp.empty();
//vector
if (scoreValue.IsArray())
{
for (size_t i = 0; i < scoreValue.Size(); ++i)
{
Value & v = scoreValue[i];
if (v.IsArray())
{
Value& col = v[0];
temp = col.GetString();
scores = atof(temp.c_str());
}
score->push_back(scores);
}
}
string str=字符串.GetString();
int i=i.Getint();
prettyJson V7.1 使用的更多相关文章
- 安卓v7支持包下的ListView替代品————RecyclerView
RecyclerView这个控件也出来很久了,相信大家也学习的差不多了,如果还没学习的,或许我可以带领大家体验一把这个艺术般的控件. 项目已经同步至github:https://github.com/ ...
- Atitit. Atiposter 发帖机 新特性 poster new feature v7 q39
Atitit. Atiposter 发帖机 新特性 poster new feature v7 q39 V8 重构iocutilV4,use def iocFact...jettyUtil V ...
- Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds
错误:Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds 错误提示就是我们限定了部署的时间导致的错 ...
- 【原创】JEECMS v6~v7任意文件上传漏洞(2)
文章作者:rebeyond 受影响版本:v6~v7 漏洞说明: JEECMS是国内Java版开源网站内容管理系统(java cms.jsp cms)的简称.该系统基于java技术开发,继承其强大.稳定 ...
- 【原创】JEECMS v6~v7任意文件上传漏洞(1)
文章作者:rebeyond 受影响版本:v6~v7 漏洞说明: JEECMS是国内Java版开源网站内容管理系统(java cms.jsp cms)的简称.该系统基于java技术开发,继承其强大.稳定 ...
- Server Tomcat v7.0 Server at localhost was unable to&nbs 报错问题解决
在eclipse启动tomcat时遇到超时45秒的问题: Server Tomcat v7.0 Server at localhost was unable to start within 45 se ...
- 转载文章-----Rational Rose2007(v7.0)下载地址、安装及激活详解教程(图)
转载地址:http://www.cnblogs.com/leaven/p/3718361.html 最近需要画uml图,之前用的是Rose 2003版的,由于好久没进去了,结果发现原来的激活又失效了, ...
- Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds -----》myeclipse2015
错误:Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds 错误提示就是我们限定了部署的时间导致的错 ...
- 80、Android Support v4、v7、v13的区别以及应用场景
一.简介 在 Android 开发中,为了使用高版本API的新特性,需要添加额外的包来使用这些新特性,这就是 Android Support 包 二.分类 Android Support v4: 这个 ...
随机推荐
- SqlCommand的四大方法
SqlCommand类的方法 ---->>>1.ExecuteNonQuery(); 它的返回值类型为int型.多用于执行增加,删除,修改数据,返回受影响的行数.当select操作时 ...
- datatable设置成中文
$('#datatable').DataTable({ language: { "sProcessing": "处理中...", "sLengthMe ...
- 【C/C++】链表的理解与使用
转载自:http://blog.csdn.NET/xubin341719/article/details/7091583/ 最近不是太忙,整理些东西,工作也许用得到. 1,为什么要用到链表 数组作为存 ...
- C++ lambda表达式 (一)
为什么要lambda函数 匿名函数是许多编程语言都支持的概念,有函数体,没有函数名.1958年,lisp首先采用匿名函数,匿名函数最常用的是作为回调函数的值.正因为有这样的需求,c++引入了lambd ...
- Fastboot线刷“复活”之刷机心得(三)——错误处理
在刷机的过程中可能不会是一帆风顺的.至少我是这种,总是会遇到这样或者那样的问题,下面是我为大家总结一些问题和解决办法,希望能对大家有所帮助. 一.电量问题 刷机和系统更新有一个共同的前 ...
- I帧、P帧和B帧的特点
I帧:帧内编码帧 I帧特点: 1.它是一个全帧压缩编码帧.它将全帧图像信息进行JPEG压缩编码及传输; 2.解码时仅用I帧的数据就可重构完整图像; 3.I帧描写叙述了图像背景和运动主体的详情; 4.I ...
- HTML5贪吃蛇源代码
显示效果例如以下:点击这里! 代码下载:点击这里! <script> function show(){ var date = new Date(); //日期对象 var ...
- jquery源码12 offset() : 位置和尺寸的方法
// Back Compat <1.8 extension point jQuery.fx.step = {}; if ( jQuery.expr && jQuery.expr. ...
- js--09定时器
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- 值得学习的CSS知识
这里零度给大家推荐几个值得学习的CSS技巧,能让你编写网页事半功倍!一.清除默认值 通常 padding 的默认值为 0,background-color 的默认值是 transparent.但是在不 ...