Advertisement
Guest User

Untitled

a guest
Oct 8th, 2012
1,190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. public class Test {
  2.     /**
  3.      * I want array be ignored, only taking into account keys
  4.      */
  5.     private static String JSON = "{\"property\":{\"key1\": {}, \"key2\": {}, \"array\":[1, 2]}}";
  6.    
  7.     @JsonIgnoreProperties(ignoreUnknown = true)
  8.     private static class MyBean {
  9.         private Map<String, Map<String, String>> property;
  10.  
  11.        
  12.         public Map<String, Map<String, String>> getProperty() {
  13.             return property;
  14.         }
  15.  
  16.         public void setProperty(Map<String, Map<String, String>> property) {
  17.             this.property = property;
  18.         }
  19.     }
  20.    
  21.     public static void main(String[] args) throws IOException {
  22.         ObjectMapper objectMapper = new ObjectMapper();
  23.         objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  24.  
  25.         objectMapper.readValue(JSON, MyBean.class);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement