สวัสดี ฉันมี LogEvent Object ที่ใช้ในฝั่งไคลเอ็นต์เพื่อบันทึกเหตุการณ์ และฉันต้องการส่งไปยังเซิร์ฟเวอร์โดยใช้ REST API ฉันกำลังแปลง LogEvent Object เป็นสตริง json และส่งเป็นเพย์โหลดผ่าน REST ในฝั่งเซิร์ฟเวอร์ฉันใช้ Groovy และเมื่อฉันพยายามทำ objectMapper.readValue() ฉันได้รับข้อผิดพลาดดังต่อไปนี้
com.fasterxml.jackson.databind.JsonMappingException: ไม่พบตัวดีซีเรียลไลเซอร์สำหรับประเภทคอลเลกชันที่ไม่ใช่คอนกรีต [ประเภทคอลเลกชัน; class org.apache.logging.log4j.ThreadContext$ContextStack มี [ชนิดธรรมดา คลาส java.lang.String]]
/// Client Side code.
private final List<LogEvent> eventQueue = new LinkedList<>();
List<LogEvent> logToSend;
eventsToSend = new ArrayList<>(eventQueue);
String jsonLogStream = new String();
ObjectMapper mapperObj = new ObjectMapper();
try{
jsonLogStream = mapperObj.writeValueAsString(logToSend);
}catch (IOException e){
e.printStackTrace();
}
closeableHttpResponse = communicationManager.executeHttpPost(uri, Collections.emptyMap(), new ByteArrayInputStream(jsonLogStream.getBytes()), false);
//// In Groovy
//
String logstream = request.getJSON().toString()
//here I'm getting LogEvents converted to json
LogEvent[] events = mapper.readValue(logstream, LogEvent[].class )
// mapper.readvalue giving error mentioned.
ฉันไม่สามารถแปลง json กลับเป็นวัตถุโดยใช้ ObjectMapper ได้ ขอบคุณสำหรับความช่วยเหลือของคุณ.