com.fasterxml.jackson.databind.exc.MismatchedInputException: 无法反序列化实例?

huangapple go评论98阅读模式
英文:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance?

问题

以下是您的文本的翻译部分:

  1. 我已经尝试了一切来读取以下JSON字符串,但仍然收到以下错误。
  2. 我的JSON字符串是有效的,我认为问题是子元素与映射有问题。
  3. 这是我的JSON字符串:
  4. [
  5. {
  6. "denotations": [
  7. {
  8. "id": [
  9. "CUI-less"
  10. ],
  11. "obj": "disease",
  12. "span": {
  13. "begin": 31,
  14. "end": 41
  15. }
  16. }
  17. ],
  18. "elapsed_time": {
  19. "ner": 2.759,
  20. "normalization": 0.002,
  21. "tmtool": 0.148,
  22. "total": 2.91
  23. },
  24. "logits": {
  25. "disease": [
  26. [
  27. {
  28. "end": 41,
  29. "id": "CUI-less",
  30. "start": 31
  31. },
  32. 0.999957799911499
  33. ]
  34. ],
  35. "drug": [],
  36. "gene": [],
  37. "species": []
  38. },
  39. "project": "BERN",
  40. "sourcedb": "PubMed",
  41. "sourceid": "2832773",
  42. "text": "Absence of humoral immunity to poliovirus in vaccinated individuals.",
  43. "timestamp": "Thu Aug 06 13:42:27 +0000 2020"
  44. }
  45. ]
  46. 我的Java POJOLogit类)
  47. import java.util.HashMap;
  48. import java.util.List;
  49. import java.util.Map;
  50. import com.fasterxml.jackson.annotation.JsonAnyGetter;
  51. import com.fasterxml.jackson.annotation.JsonAnySetter;
  52. import com.fasterxml.jackson.annotation.JsonIgnore;
  53. import com.fasterxml.jackson.annotation.JsonInclude;
  54. import com.fasterxml.jackson.annotation.JsonProperty;
  55. import com.fasterxml.jackson.annotation.JsonPropertyOrder;
  56. @JsonInclude(JsonInclude.Include.NON_NULL)
  57. @JsonPropertyOrder({
  58. "disease",
  59. "drug",
  60. "gene",
  61. "species"
  62. })
  63. public class Logits {
  64. @JsonProperty("disease")
  65. private List<List<Disease>> disease = null;
  66. @JsonProperty("drug")
  67. private List<Object> drug = null;
  68. @JsonProperty("gene")
  69. private List<Object> gene = null;
  70. @JsonProperty("species")
  71. private List<Object> species = null;
  72. @JsonIgnore
  73. private Map<String, Object> additionalProperties = new HashMap<String, Object>();
  74. @JsonProperty("disease")
  75. public List<List<Disease>> getDisease() {
  76. return disease;
  77. }
  78. @JsonProperty("disease")
  79. public void setDisease(List<List<Disease>> disease) {
  80. this.disease = disease;
  81. }
  82. @JsonProperty("drug")
  83. public List<Object> getDrug() {
  84. return drug;
  85. }
  86. @JsonProperty("drug")
  87. public void setDrug(List<Object> drug) {
  88. this.drug = drug;
  89. }
  90. @JsonProperty("gene")
  91. public List<Object> getGene() {
  92. return gene;
  93. }
  94. @JsonProperty("gene")
  95. public void setGene(List<Object> gene) {
  96. this.gene = gene;
  97. }
  98. @JsonProperty("species")
  99. public List<Object> getSpecies() {
  100. return species;
  101. }
  102. @JsonProperty("species")
  103. public void setSpecies(List<Object> species) {
  104. this.species = species;
  105. }
  106. @JsonAnyGetter
  107. public Map<String, Object> getAdditionalProperties() {
  108. return this.additionalProperties;
  109. }
  110. @JsonAnySetter
  111. public void setAdditionalProperty(String name, Object value) {
  112. this.additionalProperties.put(name, value);
  113. }
  114. }
  115. 我甚至尝试了`String[][] disease`,但仍然无法解析。
  116. 解析代码:
  117. String denotations = restTemplate.getForObject("http://com/text", String.class);
  118. System.out.println(denotations);
  119. ObjectMapper mapper = new ObjectMapper();
  120. BernOBJ denoObj = mapper.readValue(denotations, BernOBJ.class);
  121. System.out.println(denoObj);
  122. 堆栈跟踪
  123. com.fasterxml.jackson.databind.exc.MismatchedInputException:无法从START_ARRAY令牌中反序列化`com.goodyzain.bern.models.BernOBJ`实例
  124. 源:(String)"[
  125. {
  126. "denotations": [
  127. {
  128. "id": [
  129. "CUI-less"
  130. ],
  131. "obj": "disease",
  132. "span": {
  133. "begin": 31,
  134. "end": 41
  135. }
  136. }
  137. ],
  138. "elapsed_time": {
  139. "ner": 2.759,
  140. "normalization": 0.002,
  141. "tmtool": 0.148,
  142. "total": 2.91
  143. },
  144. "logits": {
  145. "disease": [
  146. [
  147. {
  148. "end": 41,
  149. "id": "CUI-less",
  150. "start": 31
  151. },
  152. 0.999957799911499
  153. ]
  154. ],
  155. "drug": [],
  156. "gene": [],
  157. "species": []
  158. },
  159. "project": "BERN",
  160. "sourcedb": "PubMed",
  161. "sourceid": "2832773",
  162. "text": "Absence of humoral immunity to poliovirus in vaccinated individuals.",
  163. "timestamp": "Thu Aug 06 13:42:27 +0000 2020"
  164. }
  165. ]"

请注意,一些HTML实体编码(如")已被翻译为双引号(")以匹配JSON格式。如果您需要更多帮助,请告诉我。

英文:

I have tried everything to read the following JSON string, but I still get the below error.
My JSON string is valid and I think the issue is that the sub element is having problem with the mapping.

Here is my JSON string:

  1. [
  2. {
  3. &quot;denotations&quot;: [
  4. {
  5. &quot;id&quot;: [
  6. &quot;CUI-less&quot;
  7. ],
  8. &quot;obj&quot;: &quot;disease&quot;,
  9. &quot;span&quot;: {
  10. &quot;begin&quot;: 31,
  11. &quot;end&quot;: 41
  12. }
  13. }
  14. ],
  15. &quot;elapsed_time&quot;: {
  16. &quot;ner&quot;: 2.759,
  17. &quot;normalization&quot;: 0.002,
  18. &quot;tmtool&quot;: 0.148,
  19. &quot;total&quot;: 2.91
  20. },
  21. &quot;logits&quot;: {
  22. &quot;disease&quot;: [
  23. [
  24. {
  25. &quot;end&quot;: 41,
  26. &quot;id&quot;: &quot;CUI-less&quot;,
  27. &quot;start&quot;: 31
  28. },
  29. 0.999957799911499
  30. ]
  31. ],
  32. &quot;drug&quot;: [],
  33. &quot;gene&quot;: [],
  34. &quot;species&quot;: []
  35. },
  36. &quot;project&quot;: &quot;BERN&quot;,
  37. &quot;sourcedb&quot;: &quot;PubMed&quot;,
  38. &quot;sourceid&quot;: &quot;2832773&quot;,
  39. &quot;text&quot;: &quot;Absence of humoral immunity to poliovirus in vaccinated individuals.&quot;,
  40. &quot;timestamp&quot;: &quot;Thu Aug 06 13:42:27 +0000 2020&quot;
  41. }
  42. ]

My Java POJO (Logit's class)

  1. import java.util.HashMap;
  2. import java.util.List;
  3. import java.util.Map;
  4. import com.fasterxml.jackson.annotation.JsonAnyGetter;
  5. import com.fasterxml.jackson.annotation.JsonAnySetter;
  6. import com.fasterxml.jackson.annotation.JsonIgnore;
  7. import com.fasterxml.jackson.annotation.JsonInclude;
  8. import com.fasterxml.jackson.annotation.JsonProperty;
  9. import com.fasterxml.jackson.annotation.JsonPropertyOrder;
  10. @JsonInclude(JsonInclude.Include.NON_NULL)
  11. @JsonPropertyOrder({
  12. &quot;disease&quot;,
  13. &quot;drug&quot;,
  14. &quot;gene&quot;,
  15. &quot;species&quot;
  16. })
  17. public class Logits {
  18. @JsonProperty(&quot;disease&quot;)
  19. private List&lt;List&lt;Disease&gt;&gt; disease = null;
  20. @JsonProperty(&quot;drug&quot;)
  21. private List&lt;Object&gt; drug = null;
  22. @JsonProperty(&quot;gene&quot;)
  23. private List&lt;Object&gt; gene = null;
  24. @JsonProperty(&quot;species&quot;)
  25. private List&lt;Object&gt; species = null;
  26. @JsonIgnore
  27. private Map&lt;String, Object&gt; additionalProperties = new HashMap&lt;String, Object&gt;();
  28. @JsonProperty(&quot;disease&quot;)
  29. public List&lt;List&lt;Disease&gt;&gt; getDisease() {
  30. return disease;
  31. }
  32. @JsonProperty(&quot;disease&quot;)
  33. public void setDisease(List&lt;List&lt;Disease&gt;&gt; disease) {
  34. this.disease = disease;
  35. }
  36. @JsonProperty(&quot;drug&quot;)
  37. public List&lt;Object&gt; getDrug() {
  38. return drug;
  39. }
  40. @JsonProperty(&quot;drug&quot;)
  41. public void setDrug(List&lt;Object&gt; drug) {
  42. this.drug = drug;
  43. }
  44. @JsonProperty(&quot;gene&quot;)
  45. public List&lt;Object&gt; getGene() {
  46. return gene;
  47. }
  48. @JsonProperty(&quot;gene&quot;)
  49. public void setGene(List&lt;Object&gt; gene) {
  50. this.gene = gene;
  51. }
  52. @JsonProperty(&quot;species&quot;)
  53. public List&lt;Object&gt; getSpecies() {
  54. return species;
  55. }
  56. @JsonProperty(&quot;species&quot;)
  57. public void setSpecies(List&lt;Object&gt; species) {
  58. this.species = species;
  59. }
  60. @JsonAnyGetter
  61. public Map&lt;String, Object&gt; getAdditionalProperties() {
  62. return this.additionalProperties;
  63. }
  64. @JsonAnySetter
  65. public void setAdditionalProperty(String name, Object value) {
  66. this.additionalProperties.put(name, value);
  67. }
  68. }

I did even try String[][] disease but it still fails to parse.

Parsing Code:

  1. String denotations = restTemplate.getForObject(&quot;http://com/text&quot;,String.class);
  2. System.out.println(denotations);
  3. ObjectMapper mapper = new ObjectMapper();
  4. BernOBJ denoObj = mapper.readValue(denotations, BernOBJ.class);
  5. System.out.println(denoObj);

Stacktrace

> com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
> deserialize instance of com.goodyzain.bern.models.BernOBJ out of
> START_ARRAY token at [Source: (String)"[
> {
> "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": [
> "[truncated 555 chars]; line: 1, column: 1] at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1468)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1242)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1190)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeFromArray(BeanDeserializer.java:604)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:190)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:166)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4482)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3434)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3402)
> ~[jackson-databind-2.11.1.jar:2.11.1] at
> com.goodyzain.bern.BernAPIController.getUsersById(BernAPIController.java:41)
> ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method) ~[na:1.8.0_252] at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> ~[na:1.8.0_252] at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> ~[na:1.8.0_252] at java.lang.reflect.Method.invoke(Method.java:498)
> ~[na:1.8.0_252] at
> org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
> ~[tomcat-embed-core-9.0.37.jar:4.0.FR] at
> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
> ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
> ~[tomcat-embed-core-9.0.37.jar:4.0.FR] at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
> ~[tomcat-embed-websocket-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
> ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE] at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
> ~[tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> [na:1.8.0_252] at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> [na:1.8.0_252] at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> [tomcat-embed-core-9.0.37.jar:9.0.37] at
> java.lang.Thread.run(Thread.java:748) [na:1.8.0_252]

答案1

得分: 5

当前的错误信息是:

Cannot deserialize instance of com.goodyzain.bern.models.BernOBJ out of START_ARRAY token at [Source: (String)&quot;[ {

这意味着您有一个JSON对象数组(以[{...开头),但尝试将其解析为单个对象:

  1. BernOBJ denoObj = mapper.readValue(denotations, BernOBJ.class);

通常情况下,数组应该被解析为值的列表,例如:

  1. List&lt;BernOBJ&gt; denoObj = mapper.readValue(denotations,
  2. mapper.getTypeFactory().constructCollectionType(List.class, BernObj.class));

此外,您的List&lt;List&lt;Disease&gt;&gt;列表并不完全包含Disease对象,它包含一个对象和一个double值:

  1. [
  2. [
  3. {
  4. &quot;end&quot;: 41,
  5. &quot;id&quot;: &quot;CUI-less&quot;,
  6. &quot;start&quot;: 31
  7. },
  8. 0.999957799911499
  9. ]
  10. ]

我不确定那里是否总是一个对象和一个数值,以及它的含义,但您可以进行以下更改。创建一个额外的类,例如DiseasePair,并将其映射如下:

  1. @JsonFormat(shape = JsonFormat.Shape.ARRAY)
  2. @JsonPropertyOrder({ &quot;disease&quot;, &quot;numericValue&quot; })
  3. class DiseasePair {
  4. private Disease disease;
  5. private Double numericValue;
  6. }

然后将您的List&lt;List&lt;Disease&gt;&gt;字段类型更改为List&lt;DiseasePair&gt;

英文:

The current error that you have:

Cannot deserialize instance of com.goodyzain.bern.models.BernOBJ out of START_ARRAY token at [Source: (String)&quot;[ {

means that you have a JSON array of objects (starting with [{...), but try to parse it into a single object:

  1. BernOBJ denoObj = mapper.readValue(denotations, BernOBJ.class);

An array is usually supposed to be parsed into a list of values, e.g. like this:

  1. List&lt;BernOBJ&gt; denoObj = mapper.readValue(denotations,
  2. mapper.getTypeFactory().constructCollectionType(List.class, BernObj.class));

Also, your List&lt;List&lt;Disease&gt;&gt; list doesn't exactly contain Disease objects, it contains an object and a double value:

  1. [
  2. [
  3. {
  4. &quot;end&quot;: 41,
  5. &quot;id&quot;: &quot;CUI-less&quot;,
  6. &quot;start&quot;: 31
  7. },
  8. 0.999957799911499
  9. ]
  10. ]

I'm not sure if there's always an object and a numeric value there, and what it means, but you could do the following. Create an additional class, e.g. DiseasePair, and map it like this:

  1. @JsonFormat(shape = JsonFormat.Shape.ARRAY)
  2. @JsonPropertyOrder({ &quot;disease&quot;, &quot;numericValue&quot; })
  3. class DiseasePair {
  4. private Disease disease;
  5. private Double numericValue;
  6. }

Then change your List&lt;List&lt;Disease&gt;&gt; field type to List&lt;DiseasePair&gt;.

huangapple
  • 本文由 发表于 2020年8月6日 21:49:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/63285033.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定