目标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. 移动端采坑:Position: fixed 在Safari上的Bug

    Position: fixed 在IOS上的显示效果 会出现两种情况: 点击fixed定位的元素会出现fixed定位失效导致的元素贴向底部,即position: absolute,bottom: 0p ...

  2. 使用 PowerShell 将数据磁盘附加到 Windows VM

    本文介绍如何使用 PowerShell 将新磁盘和现有磁盘附加到 Windows 虚拟机. 在开始之前,请查看以下提示: 虚拟机的大小决定了可以附加多少个磁盘. 有关详细信息,请参阅虚拟机大小. 若要 ...

  3. 转:C#综合揭秘——细说进程、应用程序域与上下文之间的关系

    引言 本文主要是介绍进程(Process).应用程序域(AppDomain)..NET上下文(Context)的概念与操作.虽然在一般的开发当中这三者并不常用,但熟悉三者的关系,深入了解其作用,对提高 ...

  4. android kl文件

    android kl(key layout)文件是一个映射文件,是标准linux与anroid的键值映射文件,kl文件可以有很多个,但是它有一个使用优先级: /system/usr/keylayout ...

  5. MySQL基础之 LIKE操作符

    LIKE操作符 作用:用于在WHERE子句中搜索列中的指定模式. 语法:SELECT  COLUMN_NAME  FROM  TABLE_NAME  WHERE  COLUMN_NAME  LIKE ...

  6. DevExpress 使用条形码二维码控件打印

    参考文章: https://www.cnblogs.com/wuhuacong/p/6112976.html 转载请注明出处:撰写人:伍华聪 其实主要是二维码的实现,在使用条形码控件时,又一个属性Sy ...

  7. October 16th 2017 Week 42nd Monday

    The more decisions that you are forced to make alone, the more you are aware of your freedom to choo ...

  8. 使用Socket开发http服务器时碰到的问题及处理方法

    1. 前言 ​ 最近正在为QA测试开发压力测试框架,要为测试人员提供一个结果的图形化表示界面.为了展示数据的及时性,不得不使用lua语言实现一个http服务器.由于http服务需要提供的服务比较简单 ...

  9. linux 的常用命令---------第九阶段

    Centos 7 系统启动及相关配置文件(面试题) 1. BIOS 初始化,开始post开机自检(主要检查磁盘.cpu.内存) 2. 加载 MBR 到内存 3. GRUB 阶段(可不说) 4. 加载内 ...

  10. vagrant特性——基于docker开发环境(docker和vagrant的结合)-0-简介

    原文https://www.hashicorp.com/blog/feature-preview-docker-based-development-environments Feature Previ ...