diff --git a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/simpleurl/Harvester.java b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/simpleurl/Harvester.java index 254fac91f84..2c2cbf052f3 100644 --- a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/simpleurl/Harvester.java +++ b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/simpleurl/Harvester.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.google.common.annotations.VisibleForTesting; import com.google.common.io.CharStreams; import jeeves.server.context.ServiceContext; @@ -208,7 +209,17 @@ public HarvestResult harvest(Logger log) throws Exception { private void collectRecordsFromJson(JsonNode jsonObj, Map uuids, Aligner aligner) { - JsonNode nodes = jsonObj.at(params.loopElement); + JsonNode nodes = null; + if (".".equals(params.loopElement)) { + ObjectMapper objectMapper = new ObjectMapper(); + ArrayNode jsonNodes = objectMapper.createArrayNode(); + jsonNodes.add(jsonObj); + nodes = jsonNodes; + } else { + nodes = jsonObj.at(params.loopElement); + } + + log.debug(String.format("%d records found in JSON response.", nodes.size())); nodes.forEach(jsonRecord -> {