package com.ironsource; import android.text.TextUtils; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public class dd { private static dd a = new dd(); public static dd a() { return a; } public static HashMap a(ConcurrentHashMap concurrentHashMap) throws JSONException { Object a2; HashMap hashMap = new HashMap<>(); for (Map.Entry entry : concurrentHashMap.entrySet()) { if (entry.getValue() instanceof JSONObject) { a2 = a((JSONObject) entry.getValue()); } else if (entry.getValue() instanceof JSONArray) { a2 = a((JSONArray) entry.getValue()); } else if (entry.getValue() instanceof Map) { a2 = a((Map) entry.getValue()); } else { hashMap.put(entry.getKey(), entry.getValue()); } hashMap.put(entry.getKey(), a2); } return hashMap; } public static Map a(Map map) { HashMap hashMap = new HashMap(); for (String str : map.keySet()) { hashMap.put(str, map.get(str)); } return hashMap; } public static JSONArray a(JSONArray jSONArray) { JSONArray jSONArray2 = new JSONArray(); for (int i = 0; i < jSONArray.length(); i++) { jSONArray2.put(jSONArray.opt(i)); } return jSONArray2; } public static JSONObject a(JSONObject jSONObject) throws JSONException { JSONObject jSONObject2 = new JSONObject(); Iterator keys = jSONObject.keys(); while (keys.hasNext()) { String next = keys.next(); jSONObject2.put(next, jSONObject.opt(next)); } return jSONObject2; } public static JSONObject b(JSONObject jSONObject) throws JSONException { if (jSONObject != null) { Iterator keys = jSONObject.keys(); while (keys.hasNext()) { String next = keys.next(); Object opt = jSONObject.opt(next); if (opt instanceof List) { jSONObject.put(next, TextUtils.join(",", (List) opt)); } } } return jSONObject; } }