I'd like to know how to handle 1 unmarshalling in Jackson 2.6.6 version!

Asked 1 years ago, Updated 1 years ago, 94 views

com.fasterxml.jackson.databind.JsonMappingException: Can not install value of type [map type; class java.util.HashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object] -> [Simple type, class java.Lang.Structure equipment per children's experimental equipment] at [Source: "Buying equipment for children's creative laboratory at the Children's Cultural Center of the National Asian Cultural Center"; line: 1, column: 1]

 // JsonNode Extract only required data
    JsonNode maps = mapper.readTree(jsonString).get(RESPONSE).get(BODY).get(ITEMS).get(ITEM);

If ITEM is multiple {[],[]} If the format is properly processed and works, but there is only one ITEM, it will be treated as {}. Then there will be an error, how can I deal with it if it's one case?

Java 6, Jackson 2.6.6

jackson java json

2022-09-22 14:12

3 Answers

If RESPONSE is one, does it come like {'string'}?

Presumably, RESPONSE is {[]} on the array side It's not that. ["String 1", "String 2",...] Isn't it that?

the example you gave in the question I {'string'} don't fit the JSON notation in either case...

If the server side can be modified, try modifying it to the form {data: []} or {data:'}

Note: http://www.json.org/json-ko.html


2022-09-22 14:12

{  
   "response":{  
      "header":{  },
      "body":{  
         "items":{  
            "item":[  
               {  },
               {  },
               {  },
               {  },
               {  },
               {  }
            ]
         },
         "numOfRows":999,
         "pageNo":1,
         "totalCount":6
      }
   }
}


2022-09-22 14:12

{  
   "response":{  
      "header":{  },
      "body":{  
         "items":{  
            "item":{  }
         },
         "numOfRows":999,
         "pageNo":1,
         "totalCount":1
      }
   }
}


2022-09-22 14:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.