Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何用逗号分隔数组列表值并放入hashmap_Android_Json_Post_Arraylist_Hashmap - Fatal编程技术网

Android 如何用逗号分隔数组列表值并放入hashmap

Android 如何用逗号分隔数组列表值并放入hashmap,android,json,post,arraylist,hashmap,Android,Json,Post,Arraylist,Hashmap,我在sessionList中有这种数据 现在我想运行一个循环,将这些数据放入hashmap,即键和值对,因为我想将hashmap数据发布到URL,所以我需要将会话列表中的所有值映射到hashmap中 我试过这样的东西,但没用 Map<String, String> stringMap = new HashMap<>(); for (int count = 0; count < sessionList.size(); count++) { st

我在sessionList中有这种数据

现在我想运行一个循环,将这些数据放入hashmap,即键和值对,因为我想将hashmap数据发布到URL,所以我需要将会话列表中的所有值映射到hashmap中

我试过这样的东西,但没用

 Map<String, String> stringMap = new HashMap<>();
        for (int count = 0; count < sessionList.size(); count++) {

 stringMap.put("booking_session[sessions]["+date+"][game_session]
 [" + count+"]", sessionList.get(count).split(",")[0]
        }
Map stringMap=newhashmap();
对于(int count=0;count
如您所见,我将一些字符串值放在字符串映射中,并将“date”和count值作为变量,以便可以在其中填充检索到的值。此“date”值应由逗号之前的sessionList数据填充,此行为“”sessionList.get(count).split(“,”[0]“应在逗号后填入会话列表数据,即时间会话

所以基本上结论是:


1-所有索引中逗号前的会话列表数据应填写在'date'变量中,所有索引中逗号后的数据应填写在hashmap的'value'字段中。我如何实现这一点?请帮助尽管您的代码在大多数情况下都有效,请检查以下解决方案

Map<String, String> stringMap = new HashMap<>();
for (int count = 0; count < sessionList.size(); count++) {
    stringMap.put("booking_session[sessions][" + sessionList.get(count).split(",")[0] + "][game_session] [" + count + "]", sessionList.get(count).split(",")[1]);
}
Map stringMap=newhashmap();
对于(int count=0;count

Map stringMap=newhashmap();
对于(int count=0;count
你想要什么
[“+count+”]“
哈希映射是成对的。你想要日期(逗号结果之前)作为键,时间(逗号结果之后)作为值吗?@jettimadhuChowdary是的,这正是我想要的(int count=0;countMap<String, String> stringMap = new HashMap<>(); for (int count = 0; count < sessionList.size(); count++) { String[] result = sessionList.get(count).split(","); stringMap.put(result[0], result[1]); }