Есть ли способ получить конкретную строку JSON, в которой сработало сообщение «Ожидаемое целое. Получил VALUE_STRING»?
Код:
Код: Выделить всё
public static boolean validateJson(String json, Schema schema) throws Exception {
InputStream input = new ByteArrayInputStream(json.getBytes());
DataInputStream din = new DataInputStream(input);
try {
DatumReader reader = new GenericDatumReader(schema);
Decoder decoder = DecoderFactory.get().jsonDecoder(schema, din);
reader.read(null, decoder);
return true;
} catch (AvroTypeException e) {
System.out.println(e.getMessage());
return false;
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... eexception
Мобильная версия