加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

JSONArray jsonArray解析

发布时间:2020-12-16 19:20:06 所属栏目:百科 来源:网络整理
导读:try { JSONArray jsonArray = new JSONObject(serviceMessage).getJSONArray("candidateList"); for(int i=0; ijsonArray.length(); i++){ JSONObject jsonObject = (JSONObject)jsonArray.opt(i); ResultEntity re = new ResultEntity(); int nMainIndex =
try {
JSONArray jsonArray = new JSONObject(serviceMessage).getJSONArray("candidateList");
for(int i=0; i<jsonArray.length(); i++){

JSONObject jsonObject = (JSONObject)jsonArray.opt(i);

ResultEntity re = new ResultEntity();
int nMainIndex = jsonObject.getInt("MainIndex");
String imgPath = jsonObject.getString("ImgPath");
print("fingerImgPath=>"+imgPath);
re.setFacePath(imgPath);
//"Info":"Name:xxx,Sex:男,Nation:汉族",
String info = jsonObject.getString("Info");
String[] popArr = info.split(",");
re.setName(popArr[0].split(":")[1]);
re.setSex(popArr[1].split(":")[1]);
int score = Integer.parseInt(jsonObject.getString("Score"));
score = score > 1000 ? 1000:score;
re.setScore(String.valueOf(score));
re.setTime(UtilHelper.getNowTimeStr());
re.setMatchTpye("xxx");
re.setDbName(mdb.getName());
rst.add(re);
}
} catch (JSONException e) {

e.printStackTrace();

}



//保存一副图片函数

int MAXIMGSIZE = 655360;

int SaveRawToBmp(byte[] Rawdata,StringfileName,int sensorType)

{

byte[]bmp_head_640x480 = {

0x42,0x4D,0x38,(byte)0xC3,0x04,0x00,0x36,0x28,

0x00,(byte)0x80,0x02,(byte)0xE0,0x01,0x08,(byte)0xB0,0x12,0x0B,0x00};

byte[]bmp_head_256x360 = {

0x42,0x6C,0x68,0x01};

byte[]bmp_colmap = {00,00,00};

byte[]fixarray = new byte[1024];

for(inti=0; i<1024; i++)

fixarray[i]= 0;

try {

//FileOutputStream 用于写入诸如图像数据之类的原始字节的流。要写入字符流,请考虑使用 FileWriter。

FileOutputStreamstream = new FileOutputStream(fileName);

if( sensorType == 1) //xxx

{

stream.write(bmp_head_640x480);

stream.write(bmp_colmap,3);

stream.write(bmp_colmap,3);

for(inti=0; i<480; i++)

{

bmp_colmap[0]= bmp_colmap[1] = bmp_colmap[2] = (byte)i;

stream.write(bmp_colmap);

}

stream.write(Rawdata); //直接写入即可

}

else if( sensorType== 2 ) // xxx

{

stream.write(bmp_head_256x360);

stream.write(bmp_colmap,3);

for(inti=0; i<256; i++)

{

bmp_colmap[0]= bmp_colmap[1] = bmp_colmap[2] = (byte)i;

stream.write(bmp_colmap);

}

//BMP颠倒顺序写入即可

for(inti=0; i<360; i++)

{

stream.write(Rawdata,(360-1-i)*256,256);

}

}

stream.close();

//Log.d(TAG,"SaveRawToBmp(bytes): " + oklen);

} catch(FileNotFoundException e) {

return -2;

} catch (IOException e){

return -1;

}

return 0;

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读