use of com.fasterxml.jackson.core.TreeNode in project knox by apache.
the class KnoxShellTableRowDeserializer method parseCallHistoryListJSONNode.
private List<KnoxShellTableCall> parseCallHistoryListJSONNode(TreeNode callHistoryNode) throws IOException {
final List<KnoxShellTableCall> callHistoryList = new LinkedList<>();
TreeNode callNode;
Map<Object, Class<?>> params;
String invokerClass, method;
Boolean builderMethod;
for (int i = 0; i < callHistoryNode.size(); i++) {
callNode = callHistoryNode.get(i);
invokerClass = trimJSONQuotes(callNode.get("invokerClass").toString());
method = trimJSONQuotes(callNode.get("method").toString());
builderMethod = Boolean.valueOf(trimJSONQuotes(callNode.get("builderMethod").toString()));
params = fetchParameterMap(callNode.get("params"));
callHistoryList.add(new KnoxShellTableCall(invokerClass, method, builderMethod, params));
}
return callHistoryList;
}
use of com.fasterxml.jackson.core.TreeNode in project knox by apache.
the class KnoxShellTableRowDeserializer method parseJsonWithData.
private KnoxShellTable parseJsonWithData(final TreeNode jsonContent) {
if (jsonContent.get("title").size() != 0) {
table.title(trimJSONQuotes(jsonContent.get("title").toString()));
}
final TreeNode headers = jsonContent.get("headers");
for (int i = 0; i < headers.size(); i++) {
table.header(trimJSONQuotes(headers.get(i).toString()));
}
final TreeNode rows = jsonContent.get("rows");
for (int i = 0; i < rows.size(); i++) {
TreeNode row = rows.get(i);
table.row();
for (int j = 0; j < row.size(); j++) {
table.value(trimJSONQuotes(row.get(j).toString()));
}
}
return table;
}
use of com.fasterxml.jackson.core.TreeNode in project che by eclipse.
the class CommandDeserializer method toCommand.
private List<String> toCommand(ArrayNode arrayCommandNode, DeserializationContext ctxt) throws JsonMappingException {
List<String> commands = new ArrayList<>();
for (TreeNode treeNode : arrayCommandNode) {
if (treeNode instanceof TextNode) {
TextNode textNode = (TextNode) treeNode;
commands.add(textNode.asText());
} else {
throw ctxt.mappingException("Array 'command' contains not string element.");
}
}
return commands;
}
use of com.fasterxml.jackson.core.TreeNode in project data-prep by Talend.
the class ActionDefinitionDeserializer method deserialize.
@Override
public ActionDefinition deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
final TreeNode treeNode = jp.readValueAsTree();
final TreeNode nodeName = treeNode.get("name");
if (nodeName instanceof TextNode) {
final String name = ((TextNode) nodeName).asText();
return Providers.get(ActionRegistry.class).get(name);
} else {
LOGGER.error("No action available for: {}.", treeNode);
return null;
}
}
use of com.fasterxml.jackson.core.TreeNode in project candlepin by candlepin.
the class SingleValueWrapDeserializer method deserialize.
@Override
public String deserialize(JsonParser parser, DeserializationContext context) throws IOException {
TreeNode node = parser.readValueAsTree();
if (node.isObject()) {
log.debug("Processing {} as a containing object node.", this.fieldName);
TreeNode valueNode = node.path(this.fieldName);
if (valueNode.isMissingNode()) {
throw new CandlepinJsonProcessingException("The field " + this.fieldName + " is missing from: " + node.asToken(), parser.getCurrentLocation());
}
return parseValueNode(valueNode);
} else if (node.isValueNode()) {
log.debug("Processing {} as a value node.", this.fieldName);
return parseValueNode(node);
} else {
// Uh oh.
throw new CandlepinJsonProcessingException("Unexpected " + this.fieldName + " node type: " + node.asToken(), parser.getCurrentLocation());
}
}
Aggregations