import java.io.IOException;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
public class JsonReader<T> {
public static <T> T readValue(String json) {
ObjectMapper mapper = new ObjectMapper();
try {
TypeReference<T> ref = new TypeReference<T>() {};
System.out.println(ref.getClass());
System.out.println(ref.getType());
return mapper.readValue(json, ref);
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
请问这里哪里错了,TypeReference<T>得不到T的具体类型