【问题标题】:How to proccess/read java objects from xmlrpc received by a server如何从服务器接收的 xmlrpc 处理/读取 java 对象
【发布时间】:2017-09-19 01:22:22
【问题描述】:

首先,我学习java,所以我对它完全陌生,我正在使用xmlrpc向python函数提出请愿,python发送一个字典,其中包含另一个字典,各种id列表如下:

{
    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}
}

所以我在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它。

【问题讨论】:

    标签: java python dictionary hashmap


    【解决方案1】:

    以防万一有人来到这里想知道相同或相似的问题,我发现该怎么做:

    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());
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-02
      • 1970-01-01
      • 2021-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多