我有一个JSONObject
{"2016":{"12":{"20":{"19":{"DonationTime":11111111111,"Donation":10}}}}}
Run Code Online (Sandbox Code Playgroud)
我想用每个键将它转换为新地图
int i = 0;
for (Iterator<String> keysItr = object.keySet().iterator(); keysItr.`hasNext(); i++) {
String key = keysItr.next();
Object value = object.get(key);
if(value instanceof JSONObject) {
value = toMap((JSONObject) value);
map.put(key, value);
}
}
SOP(map); //but here i want to get 4 maps
}
Run Code Online (Sandbox Code Playgroud)
我想得到4张地图
hourMap[19] = "{"DonationTime":11111111111,"Donation":10}";
dayMap[20] = "{"19":{"DonationTime":11111111111,"Donation":10}}";
monthMap[12] = "{"12":{"20":{"19":{"DonationTime":11111111111,"Donation":10}}}";
yearMap[2016] = "{"12":{"20":{"19":{"DonationTime":11111111111,"Donation":10}}}";
Run Code Online (Sandbox Code Playgroud)
我正在使用for循环但我无法获得i的递增值.