Package com.mixpanel.android.util
Class JsonUtils
java.lang.Object
com.mixpanel.android.util.JsonUtils
Utility class for JSON operations, particularly for handling arbitrary value types
encountered in feature flags.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Map<String,
MixpanelFlagVariant> parseFlagsResponse
(org.json.JSONObject responseJson) Parses the "flags" object from a /flags API response JSONObject.static Object
parseJsonValue
(Object jsonValue) Parses a JSON value obtained from org.json (like JSONObject.get() or JSONArray.get()) into a standard Java Object (String, Boolean, Number,List<Object>
,Map<String, Object>
, or null).
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
parseJsonValue
@Nullable public static Object parseJsonValue(@Nullable Object jsonValue) throws org.json.JSONException Parses a JSON value obtained from org.json (like JSONObject.get() or JSONArray.get()) into a standard Java Object (String, Boolean, Number,List<Object>
,Map<String, Object>
, or null). Handles JSONObject.NULL correctly.- Parameters:
jsonValue
- The object retrieved from org.json library.- Returns:
- The corresponding standard Java object, or null if the input was JSONObject.NULL.
- Throws:
org.json.JSONException
- if the input is an unsupported type or if nested parsing fails.
-
parseFlagsResponse
@NonNull public static Map<String,MixpanelFlagVariant> parseFlagsResponse(@Nullable org.json.JSONObject responseJson) Parses the "flags" object from a /flags API response JSONObject.- Parameters:
responseJson
- The root JSONObject from the API response.- Returns:
- A Map where keys are feature flag names (String) and values are FeatureFlagData objects. Returns an empty map if parsing fails or the "flags" key is missing/invalid.
-