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: 这个 ...
随机推荐
- 面对即将终止支持的server你还能做些什么
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaXF1c2hp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...
- 离散化求RECT1
本文转载至点击打开链接 #include<stdio.h> struct node{ int x1,y1,x2,y2,c; }; struct node s[1010]; int px[2 ...
- Gonet2 游戏server框架解析之gRPC提高(5)
上一篇blog是关于gRPC框架的基本使用,假设说gRPC仅仅是远程发几个參数,那和一个普通的http请求也没多大区别了. 所以今天我就来学习一下gRPC高级一点的用法. 流! 流能够依据用法,分为单 ...
- HDOJ 5098 Smart Software Installer 拓扑排序
拓扑排序: 两个队列,一个放不须要重新启动入度为0的,一个放须要重新启动入度为0的....从不须要重新启动的队列開始,每弹出一个数就更新下入度,遇到入读为0的就增加到对应队列里,当队列空时,记录重新启 ...
- 在VPS上用Outline Manager 建立*** 增强版服务器
在VPS上用Outline Manager 建立*** 增强版服务器 原文 https://free.com.tw/google-outline/ Outline 是Google Jigsaw的一款开 ...
- [ Linux ] 釋放記憶體指令(cache) - 轉載
1. [Linux]釋放記憶體指令(cache) http://jeffreyy.pixnet.net/blog/post/84333764-%E3%80%90linux%E3%80%91%E9%87 ...
- MHP 宿舍摄像头在门卫显示方案
通过VPN拨入公司内网,实现访问外网摄像头. 1. 宿舍和MHP公司各增加一条上网线路(可用移动) 2.宿舍处理: 2台带TF卡 摄像头,加入到萤石云端 130万摄像头+64G TF卡 3.宿 ...
- CCF模拟题 窗口
窗口 时间限制: 1.0s 内存限制: 256.0MB 问题描述 在某图形操作系统中,有 N 个窗口,每个窗口都是一个两边与坐标轴分别平行的矩形区域.窗口的边界上的点也属于该窗口.窗口之间有层次的 ...
- JS 中 this 与闭包的结合产生的问题
代码片段一: var name = "The Window"; var object = { name : "My Object", getNameFunc : ...
- struts.xml配置action没用,任意href自动跳到主页,在action中print没用?????
今晚弄了好久都搞不清楚,晕死我了. 上网找也没找到解决办法. 然后看了Build Path.好吧,有几个没用的jar包,remove之.我去,马上正常了,具体原因未知. 总结:删除jar包不代表Bui ...