Ich konvertiere Json in avro. Ich habe JSON Daten in JSONArray
. Also, während ich es in Byte-Array umwandle, stehe ich vor dem Problem.Json zu avro Umwandlung
unten ist mein Code:
static byte [] fromJsonToAvro(JSONArray json, String schemastr) throws Exception {
ExcelToJson ejj = new ExcelToJson();
List<String> list = new ArrayList<String>();
if (json != null) {
int len = json.length();
for (int i=0;i<len;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
So, wie ich es tun kann? Wie man das JsonArray-Objekt in Bytes umwandelt (d. H., Wie man die Methode getBytes() für JsonArray-Objekte verwendet). Der obige Code gibt einen Fehler bei list.getBytes()
und sagt getBytes() ist für Liste nicht definiert.