Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(HashMap<String, Integer> aString : value){
- System.out.println("key : " + key + " value : " + aString);
- }
- key : My Name value : {SKI=7, COR=13, IN=30}
- ArrayList<Integer> array = new ArrayList<Integer>();
- JSONArray json = new JSONArray(aString);
- for (int i =0; i< json.length(); i++) {
- array.add(json.getInt(i));
- }
- Map mp;
- .....
- Iterator it = mp.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pairs = (Map.Entry)it.next();
- System.out.println(pairs.getKey() + " = " + pairs.getValue());
- String key = pairs.getKey();
- String value = pairs.getValue();
- //Do something with the key/value pair
- }
- ArrayList < String > ski = new ArrayList < String > ();
- ArrayList < String > cor = new ArrayList < String > ();
- ArrayList < String > in = new ArrayList < String > ();
- for (HashMap < String, Integer > aString: value) {
- System.out.println("key : " + key + " value : " + aString);
- aString.replace("{", "");
- aString.replace("}", "");
- String[] items = aString.split(", ");
- for (String str: items) {
- if (str.contains("SKI")) {
- String skiPart = str.split("=");
- if (skiPart.length == 2) ski.add(skiPart[1]);
- }
- elseif(str.contains("COR")) {
- String corPart = str.split("=");
- if (corPart.length == 2) cor.add(corPart[1]);
- }
- elseif(str.contains("IN")) {
- String inPart = str.split("=");
- if (inPart.length == 2) in.add(inPart[1]);
- }
- }
- }
- ArrayList<HashMap<String, Object>> userNotifications = new ArrayList<HashMap<String, Object>>();
- int count = 0;
- HashMap<String, Object> notificationItem = new HashMap<String, Object>();
- notificationItem.put("key1", "value1");
- notificationItem.put("key2", "value2");
- userNotifications.add(count, notificationItem);
- count++;
- ArrayList<HashMap<String, Object>> resultGetLast5PushNotificationsByUser = new ArrayList<HashMap<String, Object>>();
- resultGetLast5PushNotificationsByUser = methodThatReturnsAnArrayList();
- HashMap<String, Object> item1= resultGetLast5PushNotificationsByUser.get(0);
- String value1= item1.get("key1");
- String value2= item1.get("key2");
- HashMap<String, Object> item1= resultGetLast5PushNotificationsByUser.get(1);
- String value1= item1.get("key1");
- String value2= item1.get("key2");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement