Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.mixpanel.mixpanelapi.featureflags.provider.BaseFlagsProvider;
import com.mixpanel.mixpanelapi.featureflags.provider.LocalFlagsProvider;
import dev.openfeature.sdk.*;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -263,6 +265,9 @@ private static Value objectToValue(Object obj) {
if (obj == null) {
return new Value();
}
if (obj == JSONObject.NULL) {
return new Value();
}
if (obj instanceof Boolean) {
return new Value((Boolean) obj);
}
Expand Down Expand Up @@ -310,6 +315,22 @@ private static Value objectToValue(Object obj) {
}
return new Value(values);
}
if (obj instanceof JSONObject) {
JSONObject json = (JSONObject) obj;
Map<String, Value> structure = new HashMap<>();
for (String key : json.keySet()) {
structure.put(key, objectToValue(json.get(key)));
}
return new Value(new ImmutableStructure(structure));
}
if (obj instanceof JSONArray) {
JSONArray arr = (JSONArray) obj;
ArrayList<Value> values = new ArrayList<>();
for (int i = 0; i < arr.length(); i++) {
values.add(objectToValue(arr.get(i)));
}
return new Value(values);
}
return new Value(obj.toString());
}
}
Loading