com.yy.httpproxy.service.PushedNotification Maven / Gradle / Ivy
package com.yy.httpproxy.service;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by xuduo on 11/6/15.
*/
public class PushedNotification {
public HashMap values;
public String id;
public PushedNotification(String id, JSONObject object) {
this.id = id;
values = jsonToMap(object);
}
public PushedNotification(String id, HashMap map) {
this.id = id;
values = map;
}
public static HashMap jsonToMap(JSONObject json) {
if (json != JSONObject.NULL) {
try {
return toMap(json);
} catch (JSONException e) {
}
}
return new HashMap<>();
}
public static HashMap toMap(JSONObject object) throws JSONException {
HashMap map = new HashMap();
Iterator keysItr = object.keys();
while (keysItr.hasNext()) {
String key = keysItr.next();
Object value = object.get(key);
if (value instanceof JSONArray) {
value = toList((JSONArray) value);
} else if (value instanceof JSONObject) {
value = toMap((JSONObject) value);
}
map.put(key, value);
}
return map;
}
public static List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy