美好的一天,我正在开发Android中的应用程序,我必须能够接收JSON数组并将其转换为普通的旧POJO arraylist。我使用GSON来实现这一点,即
Gson gson = new Gson();
ArrayList<AccountTypesRegistered> list = gson.fromJson(responseBody.string(),
new TypeToken<ArrayList<AccountTypesRegistered>>() {
}.getType());
但是,如果我尝试这样做:
try {
for (int i = 0; i < list.size(); i++) {
AccountTypesRegistered checklist = list.get(i);
Log.e("JsonObject", checklist.toString());
Log.e("Name", checklist.getClientNames());
}
} catch (Exception e) {
e.printStackTrace();
}
我在logcat中收到此错误消息:
12-16 03:31:44.371: E/JsonObject(5121): com.nickSoft.dbhelper.AccountTypesRegistered@41d73610
12-16 03:31:44.371: W/System.err(5121): java.lang.NullPointerException: println needs a message
12-16 03:31:44.371: W/System.err(5121): at android.util.Log.println_native(Native Method)
12-16 03:31:44.371: W/System.err(5121): at android.util.Log.e(Log.java:232)
12-16 03:31:44.371: W/System.err(5121): at com.nickSoft.Connections.OkHttpHandlerIncoming$1.onResponse(OkHttpHandlerIncoming.java:91)
12-16 03:31:44.371: W/System.err(5121): at okhttp3.RealCall$AsyncCall.execute(RealCall.java:126)
12-16 03:31:44.371: W/System.err(5121): at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
12-16 03:31:44.371: W/System.err(5121): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
12-16 03:31:44.371: W/System.err(5121): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
12-16 03:31:44.371: W/System.err(5121): at java.lang.Thread.run(Thread.java:841)
这是我的JSON:
[
{
"AccountType": "15516321",
"CustomerName": "1MACMONSAM NICOLAS",
"Currentbalance": "1100,000.00",
"AccountKey": "",
"AllTransactions": [
{
"ID": 103,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5001",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:40",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 105,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5002",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 107,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5003",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 109,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5004",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 111,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5005",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 113,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5006",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 115,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5007",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 117,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5008",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 119,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5009",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 121,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "50010",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 103,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "01",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 105,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "02",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 107,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "03",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 109,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "04",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 111,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "05",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 113,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "06",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 115,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "07",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 117,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "08",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 119,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "09",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 121,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "010",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 103,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5001",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 105,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5002",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 107,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5003",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 109,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5004",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 111,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5005",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 113,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5006",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 115,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5007",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 117,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5008",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 119,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5009",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 121,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "50010",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
}
]
},
{
"AccountType": "25526322",
"CustomerName": "2MACMONSAM NICOLAS",
"Currentbalance": "2100,000.00",
"AccountKey": "",
"AllTransactions": [
{
"ID": 103,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5001",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:40",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 105,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5002",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 107,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5003",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 109,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5004",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 111,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5005",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 113,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5006",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 115,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5007",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 117,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5008",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 119,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5009",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 121,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "50010",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 103,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "01",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 105,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "02",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 107,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "03",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 109,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "04",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 111,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "05",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 113,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "06",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 115,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "07",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 117,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "08",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 119,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "09",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 121,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "010",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 103,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5001",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 105,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5002",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 107,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5003",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 109,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5004",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 111,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5005",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 113,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5006",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 115,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5007",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 117,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5008",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 119,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5009",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 121,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "50010",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
}
]
},
{
"AccountType": "35536323",
"CustomerName": "3MACMONSAM NICOLAS",
"Currentbalance": "3100,000.00",
"AccountKey": "",
"AllTransactions": [
{
"ID": 103,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5001",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:40",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 105,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5002",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 107,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5003",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 109,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5004",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 111,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5005",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 113,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5006",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 115,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5007",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 117,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5008",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 119,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "5009",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 121,
"DescriptionoOfTransaction": "I need money right now",
"Debit": "50010",
"Credit": "0",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
},
{
"ID": 103,
"DescriptionoOfTransaction": "I'am putting in money right now",
"Debit": "01",
"Credit": "1500",
"TransactionDate": "16/12/2016 16:42:41",
"ValueDate": "16/12/2016 16:42:41"
}
]
}
]
和班级:
public class AccountTypesRegistered {
private String ClientNames;
private String AccountTypesOwnedByClient;
private ArrayList<AccountActivityObject> AccountsActivity;
private String AccountBalance;
private String AccountKey;
public AccountTypesRegistered() {
}
////////////////////////// SETTERS HERE///////////////////////////////////
public void setAccountTypesOwnedByClient(String AccountTypes) {
this.AccountTypesOwnedByClient = AccountTypes;
}
public void setAccountsActivity(ArrayList<AccountActivityObject> AccountsAct) {
this.AccountsActivity = AccountsAct;
}
public void setClientNames(String Clientna) {
this.ClientNames = Clientna;
}
public void setAccountBalance(String AccountBal) {
this.AccountBalance = AccountBal;
}
public void setAccountKey(String Acctkey) {
this.AccountKey = Acctkey;
}
/////////////////////// GETTERS
/////////////////////// HERE////////////////////////////////////////////
public String getClientNames() {
return this.ClientNames;
}
public String getAccountTypesOwnedByClient() {
return this.AccountTypesOwnedByClient;
}
public ArrayList<AccountActivityObject> getAccountsActivity() {
return this.AccountsActivity;
}
public String getAccountBalance() {
return this.AccountBalance;
}
public String getAccountKey() {
return this.AccountKey;
}
}
public class AccountActivityObject implements Parcelable {
private String IdOfTransaction;
private String DescriptionOftransaction;
private String ValueDate;
private String DateofTransaction;
private String Debit;
private String Credit;
private String Closing;
private String TransactionLinkToAccountKey;
public AccountActivityObject() {
}
/**
* Use when reconstructing User object from parcel This will be used only by
* the 'CREATOR'
*
* @param in
* a parcel to read this object
*/
public AccountActivityObject(Parcel in) {
this.DescriptionOftransaction = in.readString();
this.IdOfTransaction = in.readString();
this.ValueDate = in.readString();
this.DateofTransaction = in.readString();
this.Debit = in.readString();
this.Credit = in.readString();
this.Closing = in.readString();
this.TransactionLinkToAccountKey = in.readString();
}
/**
* Define the kind of object that you gonna parcel, You can use hashCode()
* here
*/
@Override
public int describeContents() {
return 0;
}
/**
* Actual object serialization happens here, Write object content to parcel
* one by one, reading should be done according to this write order
*
* @param dest
* parcel
* @param flags
* Additional flags about how the object should be written
*/
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(DescriptionOftransaction);
dest.writeString(IdOfTransaction);
dest.writeString(ValueDate);
dest.writeString(DateofTransaction);
dest.writeString(Debit);
dest.writeString(Credit);
dest.writeString(Closing);
dest.writeString(TransactionLinkToAccountKey);
}
/**
* This field is needed for Android to be able to create new objects,
* individually or as arrays
*
* If you don’t do that, Android framework will through exception Parcelable
* protocol requires a Parcelable.Creator object called CREATOR
*/
public static final Parcelable.Creator<AccountActivityObject> CREATOR = new Parcelable.Creator<AccountActivityObject>() {
public AccountActivityObject createFromParcel(Parcel in) {
return new AccountActivityObject(in);
}
public AccountActivityObject[] newArray(int size) {
return new AccountActivityObject[size];
}
};
// use this to text for equality of objects
@Override
public boolean equals(Object obj) {
if (obj instanceof AccountActivityObject) {
AccountActivityObject toCompare = (AccountActivityObject) obj;
return (this.IdOfTransaction.equalsIgnoreCase(toCompare.getIdOfTransaction()));
}
return false;
}
@Override
public int hashCode() {
return (this.getIdOfTransaction()).hashCode();
}
///////////////// SET METHODS/////////////////////////////////////////////
public void setIdOfTransaction(String IDoftransaction) {
IdOfTransaction = IDoftransaction;
}
public void setDescriptionOftransaction(String Descriptiontransaction) {
DescriptionOftransaction = Descriptiontransaction;
}
public void setValueDate(String ValueDateTransaction) {
ValueDate = ValueDateTransaction;
}
public void setDateofTransaction(String DateTransaction) {
DateofTransaction = DateTransaction;
}
// set Debit if available
public void setDebit(String DebitAmt) {
Debit = DebitAmt;
}
// set Credit
public void setCredit(String CreditAmt) {
Credit = CreditAmt;
}
// Always set closing
public void setClosing(String ClosingAmt) {
Closing = ClosingAmt;
}
public void setTransactionLinkToAccountKey(String TransacLinkToAccountKey) {
TransactionLinkToAccountKey = TransacLinkToAccountKey;
}
///////////////// GET METHODS/////////////////////////////////////////////
public String getValueDate() {
return ValueDate;
}
public String getDateofTransaction() {
return DateofTransaction;
}
public String getIdOfTransaction() {
return IdOfTransaction;
}
public String getDescriptionOftransaction() {
return DescriptionOftransaction;
}
// get show Debit if available
public String getDebit() {
return Debit;
}
// get show Credit if available
public String getCredit() {
return Credit;
}
// get show Closing
public String getClosing() {
return Closing;
}
public String getTransactionLinkToAccountKey() {
return TransactionLinkToAccountKey;
}
}
请如何解决问题并从JSON中获取我的arraylist。欢迎任何帮助
答案 0 :(得分:0)
这是POST
还是response
?你的JSON看起来很好。不熟悉API,但我认为它可能是四件事之一:
如果发布,您可能希望将其转换为javascript对象而不是JSON对象。
AccountType:“15516321”,客户名称:“1MACMONSAM NICOLAS”,Currentbalance:“1100,000.00”,AccountKey:“”,...
根据您发送/接收对象的方式,您可能已超出数据量。
如果您查看您的开发控制台是JSON字符串错误?如果字符串对象不好,开发控制台通常会告诉您。也许你必须对对象进行编码。
您的课程未正确定义,因此无法处理数据
修改强>
由于这是一个响应,您将能够确定服务器端类对象是否正确处理数据。由于你有嵌套数组,我几乎猜测类对象需要更新它的属性。如果它进入你的浏览器,你可以使用Dev Console查看该对象,我怀疑这是cas,因为你的堆栈跟踪可以识别问题。
答案 1 :(得分:0)
你的模型类是错误的..你应该有与json的键相同的变量名。与CustomerName一样,您应该在模型类中将CustomerName作为变量。
或
使用此http://www.jsonschema2pojo.org/。它将你的json转换成POJO ......
答案 2 :(得分:0)
Json不包含ClientNames字段,因此它将在反序列化的Object中填充为null。
在您的日志中,以下行会抛出Null Pointer,因为它的前一个语句已正确记录。 Log.e(“Name”,checklist.getClientNames());
这意味着Log.e函数将checklist.getClientNames()作为null并在尝试处理时抛出NPE。
尝试在JSon中添加ClientNames字段,它可以正常工作。