Skip to content

Commit

Permalink
fix for getDataAsStringList in json arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
litvinovg committed Apr 19, 2024
1 parent 8e90a1e commit 6273595
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package edu.cornell.mannlib.vitro.webapp.dynapi.data.implementation;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

Expand Down Expand Up @@ -86,8 +87,17 @@ public void addRow(String jsonPath, JacksonJsonContainer row) {

public List<String> getDataAsStringList() {
List<String> result = new LinkedList<>();
for (Data data : dataMap.values()) {
result.add(data.getSerializedValue());
if (dataMap.isEmpty()) {
JsonNode node = (JsonNode) documentContext.json();
Iterator<JsonNode> elements = node.elements();
while (elements.hasNext()) {
JsonNode element = elements.next();
result.add(element.asText());
}
} else {
for (Data data : dataMap.values()) {
result.add(data.getSerializedValue());
}
}
return result;
}
Expand Down

0 comments on commit 6273595

Please sign in to comment.