Привет, я пробую все возможные изменения для чтения следующей строки json, но все равно получаю следующую ошибку: моя json строка действительна, и проблема в том, что у подэлемента проблемы с отображением
Вот моя json строка
[
{
"denotations": [
{
"id": [
"CUI-less"
],
"obj": "disease",
"span": {
"begin": 31,
"end": 41
}
}
],
"elapsed_time": {
"ner": 2.759,
"normalization": 0.002,
"tmtool": 0.148,
"total": 2.91
},
"logits": {
"disease": [
[
{
"end": 41,
"id": "CUI-less",
"start": 31
},
0.999957799911499
]
],
"drug": [],
"gene": [],
"species": []
},
"project": "BERN",
"sourcedb": "PubMed",
"sourceid": "2832773",
"text": "Absence of humoral immunity to poliovirus in vaccinated individuals.",
"timestamp": "Thu Aug 06 13:42:27 +0000 2020"
}
]
Мой java pojo (класс Lo git)
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"disease",
"drug",
"gene",
"species"
})
public class Logits {
@JsonProperty("disease")
private List<List<Disease>> disease = null;
@JsonProperty("drug")
private List<Object> drug = null;
@JsonProperty("gene")
private List<Object> gene = null;
@JsonProperty("species")
private List<Object> species = null;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonProperty("disease")
public List<List<Disease>> getDisease() {
return disease;
}
@JsonProperty("disease")
public void setDisease(List<List<Disease>> disease) {
this.disease = disease;
}
@JsonProperty("drug")
public List<Object> getDrug() {
return drug;
}
@JsonProperty("drug")
public void setDrug(List<Object> drug) {
this.drug = drug;
}
@JsonProperty("gene")
public List<Object> getGene() {
return gene;
}
@JsonProperty("gene")
public void setGene(List<Object> gene) {
this.gene = gene;
}
@JsonProperty("species")
public List<Object> getSpecies() {
return species;
}
@JsonProperty("species")
public void setSpecies(List<Object> species) {
this.species = species;
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
Даже попытка String [] [] болезнь все еще терпит неудачу для анализа, дайте мне знать, что мне здесь не хватает
Код синтаксического анализа
String denotations = restTemplate.getForObject("http://com/text",String.class);
System.out.println(denotations);
ObjectMapper mapper = new ObjectMapper();
BernOBJ denoObj = mapper.readValue(denotations, BernOBJ.class);
System.out.println(denoObj);
Stacktrace
com.faster xml .jackson.databind.ex c .MismatchedInputException: невозможно десериализовать экземпляр com.goodyzain.bern.models.BernOBJ
из токена START_ARRAY в [Источник: (Строка) »[{« обозначения »: [{« id »: [« Без CUI) "]," obj ":" болезнь "," span ": {" begin ": 31," end ": 41}}]," elapsed_time ": {" ner ": 2.759," normalization ": 0,002," tmtool ": 0,148," всего ": 2,91}," логиты ": {" болезнь ": [" [усеченные 555 символов]; строка: 1, столбец: 1] на com.faster xml .jackson.databind.ex c .MismatchedInputException.from (MismatchedInputException. java: 59) ~ [jackson-databind-2.11.1.jar: 2.11 .1] на com.faster xml .jackson.databind.DeserializationContext.reportInputMismatch (DeserializationContext. java: 1468) ~ [jackson-databind-2.11.1.jar: 2.11.1] на com.faster xml .jackson.databind.DeserializationContext.handleUnexpectedToken (DeserializationContext. java: 1242) ~ [jackson-databind-2.11.1.jar: 2.11.1] at com.faster xml .jackson.databind.DeserializationContext.handleUnexpectedToken (DeserializationContext . java: 1190) ~ [jackson-databind-2.11.1.jar: 2.11.1] на com.faster xml .jackson.databind.deser.BeanDeserializer._deserializeFromArray (BeanDeserializer. java: 604) ~ [jackson-databind-2.11.1.jar: 2.11.1] на com.faster xml .jackson.databind.deser.BeanDeserializer._deserializeOther (BeanDeserializer. java: 190) ~ [jackson-databind-2.11.1 .jar: 2.11.1] на com.faster xml .jackson.databind.deser.BeanDeserializer.deserializ e (BeanDeserializer. java: 166) ~ [jackson-databind-2.11.1.jar: 2.11.1] на com.faster xml .jackson.databind.ObjectMapper._readMapAndClose (ObjectMapper. java: 4482) ~ [jackson-databind-2.11.1.jar: 2.11.1] на com.faster xml .jackson.databind.ObjectMapper.readValue (ObjectMapper. java: 3434) ~ [jackson-databind-2.11.1. jar: 2.11.1] на com.faster xml .jackson.databind.ObjectMapper.readValue (ObjectMapper. java: 3402) ~ [jackson-databind-2.11.1.jar: 2.11.1] на com.goodyzain .bern.BernAPIController.getUsersById (BernAPIController. java: 41) ~ [классы /: na] в sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод) ~ [na: 1.8.0_252] в sun.reflect.NativeImplhodAccessor (NativeMethodAccessorImpl. java: 62) ~ [na: 1.8.0_252] в sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl. java: 43) ~ [na: 1.8.0_252] в java .lang.reflect .Method.invoke (Method. java: 498) ~ [na: 1.8.0_252] в org.springframework.web.method.support.InvocableHandlerMethod.doInvoke (InvocableHandlerMethod. java: 190) ~ [spring-web-5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest (InvocableHandlerMethod. java: 138) ~ [ spring-web-5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.servlet. mvc .method.annotation.ServletInvocableHandlerMethod.invokeAndHandle (ServletInvocableHandlerMethod. java Spring -web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.servlet. mvc .method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod (RequestMappingHandlerAdapter: 87 * 1061 ~ [spring-web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.servlet. mvc .method.annotation.RequestMappingHandlerAdapter.handleInternal (RequestMappingHandlerAdapter. java: 792 ) ~ [spring-web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.servlet. mvc .method.AbstractHandlerMethodAdapter.handle (AbstractHandlerMethodAdapter. java: 87 ) ~ [spring-web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в o rg.springframework.web. servlet.DispatcherServlet.doDispatch (DispatcherServlet. java: 1040) ~ [spring-web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.servlet.DispatcherServlet.doService ( DispatcherServlet. java: 943) ~ [spring-web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet. java: 1006) ~ [spring-web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet. java: 898) ~ [spring- web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в javax.servlet.http.HttpServlet.service (HttpServlet. java: 626) ~ [tomcat-embed-core-9.0.37. jar: 4.0.FR] в org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet. java: 883) ~ [spring-web mvc -5.2.8.RELEASE.jar: 5.2.8.RELEASE] в javax.servlet.http.HttpServlet.service (HttpServlet. java: 733) ~ [tomcat-embed-core-9.0.37.jar: 4.0.FR] в org. apache .catalina.core.ApplicationFilterChain. internalDoFilter (ApplicationFilterChain. java: 231) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed -core-9.0.37.jar: 9.0.37] в орг. apache .tomcat.websocket.server.WsFilter.doFilter (WsFilter. java: 53) ~ [tomcat-embed-websocket-9.0.37. jar: 9.0.37] в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в org.springframework.web.filter.RequestContextFilter.doFilterIn (RequestContextFilter. java: 100) ~ [spring-web-5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 119) ~ [spring-web-5.2.8.RELEASE.jar: 5.2.8.RELEASE] в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core -9.0.37. jar: 9.0.37] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в орг. springframework.web.filter.FormContentFilter.doFilterInternal (FormContentFilter. java: 93) ~ [spring-web-5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org.springframework.web.filter.OncePerRequestFilter.do (OncePerRequestFilter. java: 119) ~ [spring-web-5.2.8.RELEASE.jar: 5.2.8.RELEASE] в org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core -9.0.37.jar: 9.0.37] в org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter. java: 201) ~ [spring-web-5.2.8.RELEASE.jar: 5.2.8. RELEASE] в org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 119) ~ [spring-web-5.2.8.RELEASE.jar: 5.2.8. RELEASE] в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в орг. apache. catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в организации apache .catalina.core.StandardWrapperValve.invoke (StandardWrapperValve . java: 202) ~ [tomcat-embed-core-9.0.37.jar: 9.0.37] в организации apache .catalina.core.StandardContextValve.invoke (StandardContextValve. java: 96) [tomcat -embed-core-9.0.37.jar: 9.0.37] в орг. apache .catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase. java: 541) [tomcat-embed-core-9.0.37.jar : 9.0.37] в org. apache .catalina.core.StandardHostValve.invoke (StandardHostValve. java: 139) [tomcat-embed-core-9.0.37.jar: 9.0.37] в org. apache .catalina.valves.ErrorReportValve.invoke (ErrorReportValve. java: 92) [tomcat-embed-core-9.0.37.jar: 9.0.37] в org. apache .catalina.core.StandardEngineValve.invoke (StandardEngineValve. java: 74) [tomcat-embed-core-9.0.37.jar: 9.0.37] в org. apache .catalina.connector. CoyoteAdapter.service (CoyoteAdapter. java: 343) [tomcat-embed-core-9.0.37.jar: 9.0.37] в орг. apache .coyote.http11.Http11Processor.service (Http11Processor. java: 373) [tomcat-embed-core-9.0.37.jar: 9.0.37] в org. apache .coyote.AbstractProcessorLight.process (AbstractProcessorLight. java: 65) [tomcat-embed-core-9.0.37 .jar: 9.0.37] в орг. apache .coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol. java: 868) [tomcat-embed-core-9.0.37.jar: 9.0.37] в орг. apache .tomcat.util. net .NioEndpoint $ SocketProcessor.doRun (NioEndpoint. java: 1589) [tomcat-embed-core-9.0.37.jar: 9.0.37] в орг. apache. tomcat.util. net .SocketProcessorBase.run (SocketProcessorBase. java: 49) [tomcat-embed-core-9.0.37.jar: 9.0.37] в java .util.concurrent.ThreadPoolExecutor.runWorker ( ThreadPoolExecutor. java: 1149) [na: 1.8.0_252] в java .util.concurrent.Thr eadPoolExecutor $ Worker.run (ThreadPoolExecutor. java: 624) [na: 1.8.0_252] в org. apache .tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread. java: 61) [tomcat -embed-core-9.0.37.jar: 9.0.37] на java .lang.Thread.run (Thread. java: 748) [na: 1.8.0_252]