📜  json数组到java代码示例中的列表

📅  最后修改于: 2022-03-11 14:52:28.355000             🧑  作者: Mango

代码示例4
// Top of file
import java.lang.reflect.Type;

// ...

private void parseJSON() {
    Gson gson = new Gson();
    Type type = new TypeToken>(){}.getType();
    List contactList = gson.fromJson(jsonString, type);
    for (ContactModel contact : contactList){
        Log.i("Contact Details", contact.id + "-" + contact.name + "-" + contact.email);
    }
}