2011-07-29 64 views
0

用於同步的目的,我寫WCF service.That的服務回報JSON作爲字符串像這樣Android的WCF JSON結果

{ 「表1」:[{ 「BusinessUnit」: 「SAMA」, 「WarehouseCode」: 「WWAT」 「LocationCode」:「WT03」,「ProductCode」:「500086」,「Stock」:「999.00」,「LastUpdatedOn」:「Jul 29 2011 11:25 AM」,「LastUpdatedBy」:「WAT2」}]} {「Table1 「:}} 0 {」Table1「:]} {」Table1「:[{」BatchSerialNumber「:」1「,」BusinessUnit「:」SAMA「,」DateFrom「:」May 5 2011 12:00 AM「,」 「:」May 5 2100 2:53 PM「,」Price「:」4.50「,」PriceGroup「:」WHSL「,」PricePer「:」1「,」ProductCode「:」501393「,」Quantity「 },{「BatchSerialNumber」:「1」,「BusinessUnit」:「SAMA」,「DateFrom」:「2011年5月5日12:00」,「DateTo」:「May 5 2100 2:53 PM」,「Price」 33.79「,」PriceGroup「:」WHSL「,」PricePer「:」1「,」ProductCode「:」501817「,」Quantity「:」1.00「}, {「BatchSerialNumber」:「1」,「BusinessUnit」:「SAMA」,「DateFrom」:「May 5 2011 12:00 AM」,「DateTo」:「May 5 2100 2:53 PM」,「Price」:「44.55」 ,「PriceGroup」:「WHSL」,「PricePer」:「1」,「ProductCode」:「603973」,「Quantity」:「1.00」},{「BatchSerialNumber」:「1」,「BusinessUnit」 ,「DateFrom」:「May 5 2011 12:00 AM」,「DateTo」:「May 5 2100 2:53 PM」,「Price」:「4.39」,「PriceGroup」:「WHSL」,「PricePer」 「產品代碼」:「501736」,「數量」:「1.00」}

的運行時間只有我自己知道的領域& values.How我可以在Android的過程中收作方法初探字段列表

看到我的代碼[該評論地需要調用字段]

public RDAlternativeProductDetail getSoapResponseTableDataJson(SoapPrimitive node, 
    ArrayList<String> strings) throws JSONException { 
    String result = node.toString(); 
    JSONObject jsonobject = new JSONObject(result); 
    ArrayList<String> list = new ArrayList<String>(); 
    RDAlternativeProductDetail alternativeProductDetail = new RDAlternativeProductDetail(); 
    JSONArray array = jsonobject.getJSONArray("BusinessUnit"); 
    int max = array.length(); 
    for (int i = 0; i < max; i++) { 
     JSONObject tmp = array.getJSONObject(i); 
     list.add(tmp.getString("//fileds place I want to call it")); 
     ...... 
    } 
    return RDAlternativeProductDetail ; 
} 

或如何獲取列表中的所有字段?這意味着BusinessUnit,WarehouseCode,LocationCode,ProductCode,Stock,LastUpdatedOn像這樣

請幫幫我。

在此先感謝

+0

本文的格式非常差。請確保代碼示例中不存在水平滾動文本。 – Merlin

+0

我已經完成從這個鏈接http://stackoverflow.com/questions/6872396/android-json-result-processing – Piraba

+0

我不明白你的意思是你的評論。您的JSON也無效,請嘗試使用http://jsonformatter.curiousconcept.com/ – Merlin

回答