Sto convertendo Json in avro. Ho dati json in JSONArray
. Quindi mentre lo convertiamo in array di byte, sto affrontando il problema.Conversione JSON in avro
sotto è il mio codice:
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
Così come posso farlo? Come convertire l'oggetto JsonArray in byte (ad esempio, come utilizzare il metodo getBytes() per gli oggetti JsonArray). Il codice sopra riportato che dà un errore allo list.getBytes()
e che dice getBytes() non è pronto per la lista.