如何使用webservice
从json获取byte []我的json格式如下:
[{"imgLogo":[255,216,255,224,0,16,74,70,73,70,0,1,1,0,0,1,0,1,0,0,255,219,0,132,0,
9,6,7,20,19,18,20,20,19,20,21,22,20,22,20,21,24,22,21,21,20,20,20,20,20,
24,21,20,22,24,20,20,20,23,24,28,40,32,24,26,37,28,20,
21,33,49,33,37,41,43,46,46,46,23,31,51,56,51,44,55,40,45,46,43,1,10,10,10
,14,13,14,27,16,16,26,44,36,28,36,44,44,44,44,44,44,44,44,44,44,44,44,
44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,
44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,255,192,0,17,8,0,194,1,3,3....]}]
我正在使用以下代码来获取这样的json值:
JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
String imagestring = jsonChildNode.getString("imgLogo");
现在,我将byte []值高于字符串。那我怎么能把这个字符串转换为byte []
答案 0 :(得分:0)
首先创建一个包含数据的String,然后
byte[] data = Base64.decode(iconString, Base64.DEFAULT);
现在你有包含你的位图的字节数组。
答案 1 :(得分:0)
使用此getBytes
方法:
byte[] bytes = imagestring .getBytes("UTF-8");