2017-04-21 33 views
1

首先,即時學習java,所以我對它是全新的,我正在向xmlrpc發出一個python函數請求,python發送一個包含另一個字典的字典裏面,各種IDS名單如下:如何從服務器接收到的xmlrpc中讀取/讀取java對象

{ 
    country_ids=[1,2,3,4,6,7,8], 
    state_ids=[23,22,12,12,56,12,56,72,23], 
    config={GLOBAL_DC=true, MAX_GLOBAL_DC=1,RET=5,COMP=1,VER=1.0} 
} 

這樣的IM與得到這個在Java中:

HashMap<String, Object> data=HashMap<String, Object> xmlrpc.call... 

,我得到的東西是這樣的:

{ 
    country_ids=[Ljava.lang.Object;@7e0aa6f, 
    state_ids=[Ljava.lang.Object;@dc6c405, 
    config={GLOBAL_DC=true, MAX_GLOBAL_DC=1,RET=5,COMP=1,VER=1.0} 
    } 

我知道如何從散列圖中讀取值data.get(「country_ids」)但我不知道如何映射/讀取/轉換此對象以獲取其中的ID。

回答

0

萬一有人卡梅斯這裏想知道同樣的或類似的問題,我發現怎麼有許多工作要做:

Object [] country_ids = (Object[]) data.get('country_ids'); 
// To read the data of elements, something like this 
for (Integer i = 0; i < country_ids.length; i++) { 
    Log.d("Element value of " + i.toString(),country_ids[i].toString()); 
}