package com.xxx.huali.hualitest.json;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.util.base64;
public class JSONArrary2Bytes {
public static void main(String[] args) {
JSonArray data = new JSonArray();
byte[] a = new byte[]{97,0,0,0};
byte[] a1 = new byte[]{97,0,1,0};
byte[] a2 = new byte[]{97,0,2,0};
data.add(a);
data.add(a1);
data.add(a2);
System.out.println(data);
byte[] b= base64.getDecoder().decode(data[0]);
byte[] b1= base64.getDecoder().decode(data[1]);
byte[] b2= base64.getDecoder().decode(data[2]);
}
}
byte[]字节数组类型在json中存储,默认会以base64加密的方式存储,所以进行JSONArray转byte[]的时候,需要base64的解码。


![java:JSONArray转byte[]字节数组 java:JSONArray转byte[]字节数组](http://www.mshxw.com/aiimages/31/328484.png)
