json-iterator / java

jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
http://jsoniter.com/
MIT License
1.51k stars 518 forks source link

Use TypeLiteral with Class<T> #218

Closed mmaryo closed 5 years ago

mmaryo commented 5 years ago

I would like to do

public <T> void method(String body, Class<T> clazz) { JsonIterator.deserialize(body, new TypeLiteral<List<clazz>>(){}); }

Is there other way to use Class ?

With Jackson we can do TypeFactory.defaultInstance().constructParametrizedType(ArrayList.class, List.class, clazz));