Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: [add support for json array variation values] (FF-2900) #86

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion eppo/src/main/java/cloud/eppo/android/EppoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import cloud.eppo.ufc.dto.VariationType;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

Expand Down Expand Up @@ -435,7 +436,16 @@ public String getJSONStringAssignment(String flagKey, String subjectKey, String

@Nullable private JSONObject parseJsonString(String jsonString) {
try {
return new JSONObject(jsonString);
if (jsonString.trim().startsWith("{")) {
return new JSONObject(jsonString);
} else if (jsonString.trim().startsWith("[")) {
JSONArray jsonArray = new JSONArray(jsonString);
JSONObject wrapper = new JSONObject();
wrapper.put("array", jsonArray);
return wrapper;
} else {
return null;
}
} catch (JSONException e) {
return null;
}
Expand Down
Loading