本文整理匯總了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);
}
}