Note that there are some explanatory texts on larger screens.

plurals
  1. POCan xstream deserialize a complicated array?
    primarykey
    data
    text
    <p>I study xstream these days.</p> <p>But I found the xstream json tutorial which in its homepage is very simple. I have an array as follows:</p> <pre><code>{ "mails":[ { "uid":"ZC2027-mXOmcAtkfiztS0sEeJlkU25", "relatedCardNums":"8299,0000,1531|8299,0000,1531", "houseHolder":"", "subject":"no-subject", "receiveTime":"2012-05-27 00:00:00", "bankName":"上海银行", "cards":[] } ], "dealedNum":330, "nextRequestDelay":"1", "percent":"0", "filterNum":410, "resCode":"01", "dealedBillNum":43, "resMsg":"正在解析" } </code></pre> <p>I want to convert this json string to a GetMailsDataResponseDto, but I dont know how to do? Could you help me out?</p> <pre><code>package com.fund.etrading.ebankapp.base.credit.cardniu.ecardniu.dto; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import com.fund.etrading.ebankapp.base.credit.utils.FileUtils; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; public class GetMailsDataResponseDto extends ResponseBaseDto{ protected int dealedNum; protected String nextRequestDelay; protected String percent; protected int filterNum; protected int dealedBillNum; protected List mails = new ArrayList(); public List getMails() { return mails; } public int getDealedNum() { return dealedNum; } public String getNextRequestDelay() { return nextRequestDelay; } public String getPercent() { return percent; } public int getFilterNum() { return filterNum; } public int getDealedBillNum() { return dealedBillNum; } public void fromJson(String json){ try { json = FileUtils.get_content("C:\\Documents and Settings\\Administrator\\workspace\\99fund_java\\src\\com\\fund\\etrading\\ebankapp\\base\\credit\\新建 文本文档 (2).txt"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } json = "{\"root\":" + json + "}"; XStream xstream = new XStream(new JettisonMappedXmlDriver()); xstream.alias("root", this.getClass()); //xstream.addImplicitCollection(this.getClass(), "mails"); xstream.alias("mail", MailDto.class); //xstream.aliasField("cards", MailDto.class, "cards"); //xstream.aliasField("currencyData", CardDto.class, "currencyData"); //xstream.aliasField("data", CurrencyDataDto.class, "data"); xstream.fromXML(json, this); } } package com.fund.etrading.ebankapp.base.credit.cardniu.ecardniu.dto; import java.util.ArrayList; import java.util.List; import com.fund.etrading.ebankapp.base.credit.BaseDto; public class MailDto extends BaseDto{ protected String uid; protected String relatedCardNums; protected String houseHolder; protected String subject; protected String receiveTime; protected String bankName; protected List cards = new ArrayList(); public String getUid() { return uid; } public String getRelatedCardNums() { return relatedCardNums; } public String getHouseHolder() { return houseHolder; } public String getSubject() { return subject; } public String getReceiveTime() { return receiveTime; } public String getBankName() { return bankName; } public List getCards() { return cards; } } </code></pre> <p>thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload