JSON传输数组的基本操作
目标JSON结果如下:

生成JSON的的过程如下:
Document document;
Document::AllocatorType& allocator = document.GetAllocator(); //根
Value root(kObjectType); Value records(kArrayType);
for (int i = ;i< signlogList.size();i++)
{
Value record_info(kObjectType);
record_info.SetObject(); record_info.AddMember("id", signlogList[i].face_id, allocator); Value snapshot_time(kStringType);
snapshot_time.SetString(signlogList[i].snapshot_time.c_str(), allocator); record_info.AddMember("recoTime", snapshot_time, allocator); Mat faceMat = imread(signlogList[i].snapshot_url); vector<uchar> buff;//buffer for coding
vector<int> param = vector<int>();
param[]=CV_IMWRITE_JPEG_QUALITY;
param[]=;//default(95) 0-100 imencode(".jpg",faceMat,buff,param);
char* imgData = new char[buff.size()];
memset(imgData, , buff.size());
for (int ii=;ii < buff.size();ii++)
{
imgData[ii] = buff[ii];
} std::string imgBase64="";
CBase64::Encode((uchar*)imgData, buff.size(),imgBase64); delete[] imgData;
imgData = NULL; Value pic(kStringType); pic.SetString(imgBase64.c_str(), allocator); record_info.AddMember("pic", pic, allocator); record_info.AddMember("sim", signlogList[i].score, allocator); records.PushBack(record_info, allocator);
} root.AddMember("records", records, allocator); string strTime = get_current_datetime(); Value sendTime(kStringType);
sendTime.SetString(strTime.c_str(), allocator); root.AddMember("sendTime", sendTime, allocator); string strMD5 = Common::Utility::generate_md5(strTime+config_info_.tianyu_order.key); Value sign(kStringType);
sign.SetString(strMD5.c_str(), allocator); root.AddMember("sign", sign, allocator);
JSON传输数组的基本操作的更多相关文章
- 使用json传输数组实例
client.php <?php //遍历数组元素,并将元素转码 function array_iconv($data, $in_charset='GBK', $out_charset='UTF ...
- AJSX 传输数组
如果要利用ajax传输数组,或者传输多个(不知道有多少个)class的某一属性的值,例如: 要将这三个数据传入php编辑界面,图片显示有三个数据,但实际上,数据的多少是由数据库所导出的数据 决定的.如 ...
- java http post/get 服务端和客户端实现json传输
注:本文来源于<java http post/get 服务端和客户端实现json传输> 最近需要写http post接口所以学习下. 总的还是不难直接上源码! PostHttpClient ...
- json传输二进制的方案【转】
本文转自:http://wiyi.org/binary-to-string.html json 是一种很简洁的协议,但可惜的是,它只能传递基本的数型(int,long,string等),但不能传递by ...
- json在php中的使用之如何转换json为数组
<?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}' ...
- MVC中用ajax提交json对象数组
应用场景:在前端用ajax向服务器提交json对象数组,在controller的以对象数组作为函数的参数,提交的json数组直接转为服务器端的对象数组. 如: 要将json对象数组[{Id:1,Nam ...
- No1_4.数组的基本操作_Java学习笔记
import java.util.Arrays; public class HelloArrayOp { public static void main(String[] args) { // TOD ...
- list对象数组,xpath复杂定位校验,POST入参为number数组,POST入参为JSON对象数组
list对象数组: POST入参为number数组: { "typeIds":[1,2,3]} POST入参为JSON对象数组,举例: [{ "itemId& ...
- javascript:Json 和数组的遍历
首先看代码示例var json={a:1,b:2,c:3}; //json var array={1,2,3}; //数组 alert(json.a); //弹出1 或alert(json['a']) ...
随机推荐
- mongodb2.X添加权限
1.连接mongodb数据库(如果mongo命令没有做环境变量配置,需要定位到有mongo命令的目录) root@AY140709212620347s22Z:~# mongo MongoDB shel ...
- JAVA:函数的定义、使用
本文内容: 什么是函数 函数的定义格式 函数的重载(overload): 函数的调用使用注意 关于形式参数的使用 首发时间:2017-06-23 修改时间:2018-03-21:修改了布局,修改了 ...
- 让 Angular 应用动起来!
[编者按]本文主要通过生动的实例,介绍为 Angular 应用添加动画的原理与过程.文章系国内 ITOM 管理平台 OneAPM 编译呈现. 我们知道,Angular 应用在更新 DOM 时,会直接将 ...
- Oracle EBS OPM close batch
--close_batch --created by jenrry DECLARE x_message_count NUMBER; x_message_list VARCHAR2 (4000); x_ ...
- 64位的Sql Server使用OPENROWSET导入xlsx格式的excel数据的时候报错(转载)
In the old times while all the CPUs were 32bit, we were happily using JET OLEDB Provider reaching Ex ...
- 阿里云 IOT 对接设备开发 C# 开发设备对接阿里云 IOT平台
一,创建阿里云 IOT 产品.设备 目前阿里云每月赠送 100 万条流量,可以免费使用基础版.高级版,开通后即可免费使用. 阿里云 IOT 平台地址 https://iot.console.aliyu ...
- 第 14 章 结构和其他数据形式(伸缩型数组成员C99)
伸缩型数组成员C99 声明一个伸缩型数组成员的规则: 1.伸缩型数组成员必须是结构的最后一个成员: 2.结构中必须至少有一个成员: 3.伸缩数组的方括号是空的. 示例 struct flex { in ...
- shiro实战系列(五)之Authentication(身份验证)
建议学习shiro读读官方文档,虽然不一定读的懂,但是建议要大致浏览,心中有个大概,这样对于学习还是有一定帮助 官网地址:https://shiro.apache.org/ Authenticatio ...
- 无法读取配置节“oracle.manageddataaccess.client”,因为它缺少节声明
程序发布后出现问题: 无法读取配置节“oracle.manageddataaccess.client”,因为它缺少节声明 解决办法: 1.安装了odac12. ODTwithODAC121010.z ...
- MVC的BundleConfig类
在BundleConfig.cs文件中,包含了一些应用程序中使用的脚本和样式表的文件路径.并可以使用通配符.示例如下: using System.Web; using System.Web.Optim ...