3
public class ListResult<T> {

    private boolean ok;
    private String message;
    private java.util.List<T> data;
    private Paging paging;
}

When i want to deserialize JSON given form RESTful call like this :

Type fooType = new TypeToken<ListResult<T>>() {}.getType();
Gson gson = new Gson();
Object model = gson.fromJson(strResult, fooType);

A get A ListResult where data field is a list of StringMap instead a List of T like defined in ListResult class

Any idea ?


Regular expression to validate characters and numbers

I want to validate a text input field which has an input with four default characters, followed by minimum of 5 digits.

There is no restriction for maximum limit of numbers.

Eg: abcd123456

Can anyone help me with regular expression in javascript?

4

2 に答える 2

0
Type fooType = new TypeToken<ListResult<StringMap>>() {}.getType();
Gson gson = new Gson();
ListResult<StringMap> model = gson.fromJson(strResult, fooType);

Gsonあなたの心を読むことも、ジェネリック型をすべて単独で決定することもできません;)

https://sites.google.com/site/gson/gson-user-guide#TOC-Serializing-and-Deserializing-Generic-Types

于 2012-12-22T00:07:14.713 に答える
-1

リストを使用しないで、配列を使用してください MyObj[] myObjs。TypeToken の方法を使用する必要はありません

于 2013-09-25T18:26:35.103 に答える