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
11 changes: 6 additions & 5 deletions src/main/java/com/merge/api/core/QueryStringMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class QueryStringMapper {

public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) {
JsonNode valueNode = MAPPER.valueToTree(value);

// In cases where valueNode is a list of strings, we want to return a comma separated string
if (key.equals("expand")) {
String commaSeparatedQueryParams = "";

if (valueNode.isArray()) {
List<String> values = new ArrayList<>();
for (JsonNode node : valueNode) {
Expand All @@ -35,7 +35,8 @@ public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object
} else if (value instanceof String) {
String text = ((String) value).trim();
if (text.startsWith("[") && text.endsWith("]")) {
commaSeparatedQueryParams = text.replace("[", "").replace("]", "").replace(", ", ",");
commaSeparatedQueryParams =
text.replace("[", "").replace("]", "").replace(", ", ",");
}
}

Expand All @@ -44,7 +45,7 @@ public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object
return;
}
}

List<Map.Entry<String, JsonNode>> flat;
if (valueNode.isObject()) {
flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats);
Expand All @@ -58,7 +59,7 @@ public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object
}
return;
}

for (Map.Entry<String, JsonNode> field : flat) {
if (field.getValue().isTextual()) {
httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue());
Expand Down