com.cognite.client.servicesV1.response.JsonThreeDOutputsParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cdf-sdk-java Show documentation
Show all versions of cdf-sdk-java Show documentation
Java SDK for reading and writing from/to CDF resources.
package com.cognite.client.servicesV1.response;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
@AutoValue
public abstract class JsonThreeDOutputsParser extends DefaultResponseParser {
public static JsonThreeDOutputsParser.Builder builder() {
return new AutoValue_JsonThreeDOutputsParser.Builder();
}
public abstract Builder toBuilder();
@Override
public ImmutableList extractItems(String json) throws Exception {
ArrayList tempList = new ArrayList<>();
JsonNode node = objectMapper.readTree(json).path("items");
if (node.isArray()) {
LOG.debug("Found items array in json response payload.");
for (JsonNode child : node) {
if (child.isObject()) {
tempList.add(child.toString());
} else {
tempList.add(child.textValue());
}
}
return ImmutableList.copyOf(tempList);
}
LOG.info("items array not found in Json payload: \r\n" + json
.substring(0, Math.min(MAX_LENGTH_JSON_LOG, json.length())));
return ImmutableList.of();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract JsonThreeDOutputsParser build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy