本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.findPath方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.findPath方法的具体用法?Java JsonNode.findPath怎么用?Java JsonNode.findPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JsonNode
的用法示例。
在下文中一共展示了JsonNode.findPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAssignProp
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void addAssignProp(JsonNode props) throws IOException, SQLException, DataAccessException {
String name = props.get("scheme").asText();
JsonNode propNode = props.findPath("properties");
String propString = "";
if (propNode.isArray()) {
for (JsonNode p : propNode) {
propString = propString + p.textValue() + ",";
}
propString = propString.substring(0, propString.length() - 1);
} else if (propNode.isTextual()) {
propString = propNode.textValue();
} else {
Logger.error("passed property neither a list or array");
throw new IllegalArgumentException();
}
setProp("prop." + name, propString);
}
示例2: updateAssignProp
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateAssignProp(JsonNode props) throws IOException, SQLException, DataAccessException {
String name = props.get("scheme").asText();
JsonNode propNode = props.findPath("properties");
String propString = recProp("prop." + name) + ",";
if (propNode.isArray()) {
for (JsonNode p : propNode) {
propString = propString + p.textValue() + ",";
}
propString = propString.substring(0, propString.length() - 1);
} else if (propNode.isTextual()) {
propString = propString + propNode.textValue();
} else {
Logger.error("passed property neither a list or array");
throw new IllegalArgumentException();
}
chngProp("prop." + name, propString);
}
示例3: addSortListProp
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void addSortListProp(JsonNode props) throws IOException, SQLException, DataAccessException {
String name = props.get("scheme").asText();
JsonNode propNode = props.findPath("properties");
String propString = "";
if (propNode.isArray()) {
for (JsonNode p : propNode) {
propString = propString + p.textValue() + ",";
}
propString = propString.substring(0, propString.length() - 1);
} else if (propNode.isTextual()) {
propString = propNode.textValue();
} else {
Logger.error("passed property neither a list or array");
throw new IllegalArgumentException();
}
setProp("prop.sortlist." + name, propString);
}
示例4: updateSortListProp
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateSortListProp(JsonNode props) throws IOException, SQLException, DataAccessException {
String name = props.get("scheme").asText();
JsonNode propNode = props.findPath("properties");
String propString = recProp("prop.sortlist." + name) + ",";
if (propNode.isArray()) {
for (JsonNode p : propNode) {
propString = propString + p.textValue() + ",";
}
propString = propString.substring(0, propString.length() - 1);
} else if (propNode.isTextual()) {
propString = propString + propNode.textValue();
} else {
Logger.error("passed property neither a list or array");
throw new IllegalArgumentException();
}
chngProp("prop.sortlist." + name, propString);
}
示例5: getJsonValue
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static Object getJsonValue(JsonNode input, String name, Class type, boolean isRequired, Object defaultValue) throws IllegalArgumentException {
JsonNode node = input.findPath(name);
if (node.isMissingNode() || node.isNull()) {
if (isRequired) {
throw new IllegalArgumentException(name + " is required!");
} else {
return defaultValue;
}
}
if (type.equals(String.class)) {
return node.textValue();
}
if (type.equals(Integer.class)) {
return node.asInt();
}
if (type.equals(Long.class)) {
return node.asLong();
}
if (type.equals(Boolean.class)) {
return node.asBoolean();
}
if (type.equals(Double.class)) {
return node.asDouble();
}
return node.asText();
}
示例6: readValue
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
protected <T> T readValue(JsonNode node, String findPath, Class<T> valueType) {
try {
if (findPath != null) {
if (!node.has(findPath))
return null;
node = node.findPath(findPath);
}
return mapper.readValue(node.toString(), valueType);
} catch (IOException e) {
throw new RuntimeException(e);
}
}