Jackson.java // JSON转换成对象ObjectMapper mapper = new ObjectMapper();AccessToken token = mapper.readValue(result, AccessToken.class);//不创建对象,直接读取:Map map = mapper.readValue(result, Map.class)//对象转JSONObjec
// JSON转换成对象 ObjectMapper mapper = new ObjectMapper(); AccessToken token = mapper.readValue(result, AccessToken.class); //不创建对象,直接读取: Map map = mapper.readValue(result, Map.class) //对象转JSON ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeAsString(new AccessToken())build.gradle
// 导入依赖 compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.1' compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.1' compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.1'