0

I have a class as below:

class TestJson<T>{
  public String status;
  public String message;
  public ArrayList<T> result;
}

and I need define a function like this:

 TestJson<T> toJSONClass(class<T> cls);

a JSON string like this:

{"status":"1"; "message":"OK", "result":[[1, "a"],[2, "b"],[3, "c"]]}

a template class like this

class ResultClass{
  int a;
  String b;
}

the way to call toJSONClass like this:

TestJosn<ResultClass> tj = toJsonClass(ResultClass.class) 

How can I define the function to get a Instance of TestJson<ResultClass>?

LiGa
  • 159
  • 1
  • 2
  • 9

0 Answers0