JSONArray jsonArray解析

前端之家收集整理的这篇文章主要介绍了JSONArray jsonArray解析前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_403_0@try {
JSONArray jsonArray = new JSONObject(serviceMessage).getJSONArray("candidateList");
for(int i=0; i<jsonArray.length(); i++){

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

@H_403_0@ 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) {

@H_403_0@ e.printStackTrace();

@H_403_0@}

@H_403_0@

@H_403_0@

//保存一副图片函数

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;

}

原文链接:https://www.f2er.com/json/290343.html

猜你在找的Json相关文章