Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get generic type with List<Map<String, Integer>>. #76

Open
xuecangqiuye opened this issue May 7, 2024 · 0 comments
Open

How to get generic type with List<Map<String, Integer>>. #76

xuecangqiuye opened this issue May 7, 2024 · 0 comments

Comments

@xuecangqiuye
Copy link

Failed to get generic type.

class Bar {

    public static void main(String[] args) {
        List<Map<String, Integer>> list = new ArrayList<>();
        Map<String, Integer> map = new HashMap<>();
        map.put("1",1);
        list.add(map);
        Type typeArgs = TypeResolver.reify(List.class, list.getClass());
        System.out.println(JSON.toJSONString(typeArgs));
    }
}

The output is {"actualTypeArguments":["java.lang.Object"],"rawType":"java.util.List","typeName":"java.util.List<java.lang.Object>"}
Why the actualTypeArguments is 'Object', should it be a Map?
If I was wrong to use it, could you possibly provide an example solving this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant