public void testIntBooleanMap() throws Exception {
  ObjectMapper mapper=new ObjectMapper();
  String JSON="{ \"1\" : true, \"-1\" : false }";
  Map<String,Integer> result=mapper.readValue(JSON,new TypeReference<HashMap<Integer,Boolean>>(){
  }
);
  assertNotNull(result);
  assertEquals(HashMap.class,result.getClass());
  assertEquals(2,result.size());
  assertEquals(Boolean.TRUE,result.get(Integer.valueOf(1)));
  assertEquals(Boolean.FALSE,result.get(Integer.valueOf(-1)));
  assertNull(result.get("foobar"));
  assertNull(result.get(0));
}

public void testIntBooleanMap ( ) throws Exception { ObjectMapper mapper = new ObjectMapper ( ) ; String JSON = "{ \"1\" : true, \"-1\" : false }" ; Map < String , Integer > result = mapper . readValue ( JSON , new TypeReference < HashMap < Integer , Boolean > > ( ) { } ) ; assertNotNull ( result ) ; assertEquals ( HashMap . class , result . getClass ( ) ) ; assertEquals ( 2 , result . size ( ) ) ; assertEquals ( Boolean . TRUE , result . get ( Integer . valueOf ( 1 ) ) ) ; assertEquals ( Boolean . FALSE , result . get ( Integer . valueOf ( - 1 ) ) ) ; assertNull ( result . get ( "foobar" ) ) ; assertNull ( result . get ( 0 ) ) ; }
let ' s also check that it is possible to do type conversions to allow use of non - string map keys .
