我正在将Json转换为avro.我在
JSONArray中有json数据.因此,在将其转换为字节数组时,我正面临着这个问题.
下面是我的代码:
static byte [] fromJsonToAvro(JSONArray json, String schemastr) throws Exception {
ExcelToJson ejj = new ExcelToJson();
List list = new ArrayList();
if (json != null) {
int len = json.length();
for (int i=0;i
list.add(json.get(i).toString());
}
}
InputStream input = new ByteArrayInputStream(list.getBytes()); //json.toString().getBytes()
DataInputStream din = new DataInputStream(input);
.
.
.//rest of the logic
那我该怎么办呢?如何将JsonArray对象转换为字节(即,如何对JsonArray对象使用getBytes()方法).上面的代码在list.getBytes()中给出了一个错误,并且说getBytes()是针对列表的.