I have a jsonstring as below
{"coaList":[{"iD":324,"strName":"Cash","hasChildren":false,"amount":3500.0,"transDate":1421346600000},{"iD":326,"strName":"Cash","hasChildren":false,"amount":2000.0,"transDate":1421346600000},{"iD":328,"strName":"HDFC Bank","hasChildren":false,"amount":2500.0,"transDate":1421346600000}]}
I need to convert this string to CoaAccountList class object.Below is the CoaAccountList class. CoaAccountList.java:
public class CoaAccountList implements Serializable {
private List<COAAccount> coaList;
public List<COAAccount> getCoaList() {
return coaList;
}
public void setCoaList(List<COAAccount> coaList) {
this.coaList = coaList;
}
}
Where COAAccount class containing transDate as TimeStamp variable and in json string its as Long variable, so my convertion process results a com.google.gson.JsonSyntaxException for this long transDate value.Below is the code i used to convert the json string to CoaAccountList
Gson gson = new Gson();
CoaAccountList transHisList=gson.fromJson(jsonString, CoaAccountList.class);
Below is the COAAccount class.
COAAccount.java:
public class COAAccount implements Serializable {
private int iD;
private String strName;
private boolean hasChildren;
private float amount;
private Timestamp transDate;
public COAAccount() {
super();
// TODO Auto-generated constructor stub
}
public COAAccount(int iD, String strName, boolean hasChildren, float amount, Timestamp transDate) {
super();
this.iD = iD;
this.strName = strName;
this.hasChildren = hasChildren;
this.amount = amount;
this.transDate = transDate;
}
public int getiD() {
return iD;
}
public void setiD(int iD) {
this.iD = iD;
}
public String getStrName() {
return strName;
}
public void setStrName(String strName) {
this.strName = strName;
}
public boolean isHasChildren() {
return hasChildren;
}
public void setHasChildren(boolean hasChildren) {
this.hasChildren = hasChildren;
}
public float getAmount() {
return amount;
}
public void setAmount(float amount) {
this.amount = amount;
}
public Timestamp getTransDate() {
return transDate;
}
public void setTransDate(Timestamp transDate) {
this.transDate = transDate;
}
@Override
public String toString() {
return strName;
}
}
Please help me to convert this json string to CoaAccountList object.