目标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传输数组的基本操作的更多相关文章

  1. 使用json传输数组实例

    client.php <?php //遍历数组元素,并将元素转码 function array_iconv($data, $in_charset='GBK', $out_charset='UTF ...

  2. AJSX 传输数组

    如果要利用ajax传输数组,或者传输多个(不知道有多少个)class的某一属性的值,例如: 要将这三个数据传入php编辑界面,图片显示有三个数据,但实际上,数据的多少是由数据库所导出的数据 决定的.如 ...

  3. java http post/get 服务端和客户端实现json传输

    注:本文来源于<java http post/get 服务端和客户端实现json传输> 最近需要写http post接口所以学习下. 总的还是不难直接上源码! PostHttpClient ...

  4. json传输二进制的方案【转】

    本文转自:http://wiyi.org/binary-to-string.html json 是一种很简洁的协议,但可惜的是,它只能传递基本的数型(int,long,string等),但不能传递by ...

  5. json在php中的使用之如何转换json为数组

    <?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}' ...

  6. MVC中用ajax提交json对象数组

    应用场景:在前端用ajax向服务器提交json对象数组,在controller的以对象数组作为函数的参数,提交的json数组直接转为服务器端的对象数组. 如: 要将json对象数组[{Id:1,Nam ...

  7. No1_4.数组的基本操作_Java学习笔记

    import java.util.Arrays; public class HelloArrayOp { public static void main(String[] args) { // TOD ...

  8. list对象数组,xpath复杂定位校验,POST入参为number数组,POST入参为JSON对象数组

    list对象数组: POST入参为number数组: {    "typeIds":[1,2,3]} POST入参为JSON对象数组,举例: [{    "itemId& ...

  9. javascript:Json 和数组的遍历

    首先看代码示例var json={a:1,b:2,c:3}; //json var array={1,2,3}; //数组 alert(json.a); //弹出1 或alert(json['a']) ...

随机推荐

  1. JDK7下VisualVm插件无法链接到插件中心

      VisualVM 是一款免费的,集成了多个 JDK 命令行工具的可视化工具,它能为您提供强大的分析能力,对 Java 应用程序做性能分析和调优.这些功能包括生成和分析海量数据.跟踪内存泄漏.监控垃 ...

  2. smarty详细使用教程(韩顺平smarty模板技术笔记)

    MVC是一种开发模式,强调数据的输入.处理.显示是强制分离的 Smarty使用教程1.如何配置我们的smarty解压后把libs文件夹放在网站第一级目录下,然后创建两个文件夹templates 存放模 ...

  3. 无法将数据库从SINGLE_USER模式切换回MULTI_USER模式(Error 5064),及查找SQL Server数据库中用户spid(非SQL Server系统spid)的方法

    今天公司SQL Server数据库无意间变为SINGLE_USER模式了,而且使用如下语句切换回MULTI_USER失败: ALTER DATABASE [MyDB] SET MULTI_USER W ...

  4. EntityFramework Code-First 简易教程(一)

    前言:学习了EF框架这么久,还没有好好总结一番,正好遇到一国外的网站,发现不错,随即翻译过来,一是让自己复习一遍,二是供广大初学者学习,翻译过程中加入了一些自己的理解,如有错误,还请指出,多谢多谢.好 ...

  5. Windows Server 2012 R2 创建AD域

        前言 我们按照下图来创建第一个林中的第一个域.创建方法为先安装一台Windows服务器,然后将其升级为域控制器.然后创建第二台域控制器,一台成员服务器与一台加入域的Win8计算机. 环境 网络 ...

  6. JavaScript中数组slice和splice的对比小结

    前言 今天重温了一下Javascript,看到了数组的方法,其中有两个比较相似的方法——splice和splice,看着很像,就是多了一个p,但是用法却相当不一样. 在使用中,可以通过选择一个具有强语 ...

  7. 单一事件中心管理组件通信( vuex )

    有时候两个组件也需要通信(非父子关系).在简单的场景下,可以使用一个空的 Vue 实例作为中央事件总线: 补充$emit ,$on的讲解 代码: <!DOCTYPE html> <h ...

  8. 把php session 会话保存到redis

    php的session会话默认时以文件形式保存在php.ini配置文件设置的会话缓存目录,文件保存会话的效率很低,每当每个用户登录一次就会在服务器上生成一个唯一的session_id文件,当用户登录量 ...

  9. php 把一个一维数组的值依次赋值到二维数组中的每一项

    Array( [0] => 1 [1] => 4 [2] => 2 [3] => 6 ) Array( [0] => Array ( [field_name] => ...

  10. bip39

    BIP: 39 (助记词) Layer: Applications Title: Mnemonic code for generating deterministic keys Author: Mar ...