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: 这个 ...
随机推荐
- 英语影视台词---二、Inception
英语影视台词---二.Inception 一.总结 一句话总结:盗梦空间 1.You're waiting for a train..A train that will take you far aw ...
- Android 使用Gallery组件实现图片播放预览
Gallery(画廊)扩展了LayoutParams,以此提供可以容纳当前的转换信息和先前的位置转换信息的场所. Activity package com.app.test01; import com ...
- DataTable中Compute计算函数
DataTable dt = new DataTable(); //嵌套的三元运算 牛叉到五体投地 object obj = dt.Compute("iif(1000=5,1000,iif( ...
- obdg反汇编破解crackme
obdg是一个反汇编软件 直接将要反汇编的exe文件拖入或者file->open打开文件,等待一段时间就会显示出来 界面中分别为汇编代码(程序内存内容),寄存器内容,数据内存内容,栈内容 代码界 ...
- Dojo Chart之经常使用统计图
非常多做web的都知道,在非常多web系统中会涉及到一些统计图.比如饼状图,柱状图.趋势图.以及叠加图等.提到这儿,做web的都非常熟悉的,jquery的highcharts就能搞定全部的涉及到统计图 ...
- vim中使用正則表達式
一.使用正則表達式的命令 使用正則表達式的命令最常见的就是 / (搜索)命令. 其格式例如以下: /正則表達式 还有一个非常实用的命令就是 :s(替换)命令,将第一个//之间的正則表達式替换成第二个/ ...
- 第一个WPF
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 浏览器(BOM)对象的一些内置方法总结
浏览器(BOM)对象的一些内置方法总结 一.总结 1.bom就是浏览器那端执行的代码,dom就是服务器那端操作html的代码 2.记好bom的几个对象,那就很好理解很多代码了,也很好写很多代码了 二. ...
- 深入浅出微服务框架dubbo(一):基础篇
一.基础篇 1.1 开篇说明 dubbo是一个分布式服务框架,致力于提供高性能透明化RPC远程调用方案,提供SOA服务治理解决方案.本文旨在将对dubbo的使用和学习总结起来,深入源码探究原理,以备今 ...
- 44.Node.js Express 框架--web框架
转自:http://www.runoob.com/nodejs/nodejs-express-framework.html Express 简介 Express 是一个简洁而灵活的 node.js W ...