本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.textValue方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.textValue方法的具体用法?Java JsonNode.textValue怎么用?Java JsonNode.textValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JsonNode
的用法示例。
在下文中一共展示了JsonNode.textValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: extractResponse
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Nullable
private JsonNode extractResponse(JsonNode merlinResult) {
// !! handle notifications
JsonNode classField = merlinResult.get("class");
if (classField == null) {
return null;
}
JsonNode value = merlinResult.get("value");
String responseType = classField.textValue();
if ("return".equals(responseType)) {
return value;
}
// Something went wrong with merlin, it can be: failure|error|exception
// https://github.com/ocaml/merlin/blob/master/doc/dev/PROTOCOL.md#answers
if ("error".equals(responseType)) {
Notifications.Bus.notify(new RmlNotification("Merlin", responseType, value.toString(), NotificationType.ERROR, null));
}
// failure or error should not be reported to the user
return null;
}
示例4: 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();
}
示例5: getString
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
*
* 获取json传 K-V 的V值只适应于获取叶子节点的V值
* 注意:如果{"a":"b","c":{"d":"d1","e":{"f","f1"}}}
* 当 path为c时候,返回:{"d":"d1","e":{"f","f1"}}
* @param json
* @param paths
*
* @return
*/
public static String getString(@NotNull String json, @Nullable String... paths) {
JsonNode jsonNode = parseJsonNode(json, paths);
if (Check.isNull(jsonNode)) {
return null;
}
if(jsonNode.isValueNode()){
return jsonNode.textValue();
}
return toJsonString(jsonNode);
}
示例6: lisock_msg
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public void lisock_msg(String message) {
try {
JsonNode node = mapper.readTree(message);
JsonNode type = node.get("t");
JsonNode data = node.get("d");
//if (data != null) log(message); else return;
if (type != null) switch (type.textValue()) {
case "b":
for (int i=0; i < data.size(); i++) lisock_msg(data.get(i).toString());
break;
case "move":
log("New move for " + handle + ": " + data);
this.newMove(data);
JsonNode winner = data.get("winner");
if (winner != null &&
winner.asText().equals(sock.getGame().get("player").get("color").asText())) {
winner_chess(this);
}
break;
case "end":
log("End of game detected!");
if (data != null) {
log("End of game: " + data.toString());
if (data.asText().equals(sock.getGame().get("player").get("color").asText())) {
winner_chess(this);
}
}
sock.end(); //is this needed?
break;
default:
break;
}
}
catch (Exception e) { e.printStackTrace(); }
}
示例7: loadObject
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private Object loadObject(JsonNode node) {
if (node == null) return null;
try {
switch (node.getNodeType()) {
case ARRAY:
return loadArray(node);
case BINARY:
return node.binaryValue();
case BOOLEAN:
return node.booleanValue();
case MISSING:
case NULL:
return null;
case NUMBER:
return node.numberValue();
case OBJECT:
return loadDocument(node);
case POJO:
return loadDocument(node);
case STRING:
return node.textValue();
}
} catch (IOException e) {
return null;
}
return null;
}
示例8: toPluginPath
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static String toPluginPath(JsonNode pluginEntry) {
String path = pluginEntry.textValue();
// Convert to an absolute path if necessary.
// It should be enough prepending '/' because the 'plugins.json' is at the root directory.
if (path.charAt(0) != '/') {
return '/' + path;
} else {
return path;
}
}
示例9: deserialize
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public CommitMessageDto deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
final JsonNode jsonNode = p.readValueAsTree();
final JsonNode summary = jsonNode.get("summary");
if (summary == null || summary.textValue() == null) {
ctxt.reportInputMismatch(CommitMessageDto.class, "commit message should have a summary.");
// should never reach here
throw new Error();
}
final String detail = jsonNode.get("detail") == null ? "" : jsonNode.get("detail").textValue();
final JsonNode markupNode = jsonNode.get("markup");
final Markup markup = Markup.parse(markupNode == null ? "unknown" : markupNode.textValue());
return new CommitMessageDto(summary.textValue(), detail, markup);
}
示例10: process
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public void process(final Exchange exchange) throws Exception {
// parse input json and extract Id field
final Message in = exchange.getIn();
final String body = in.getBody(String.class);
if (body == null) {
return;
}
final ObjectNode node = (ObjectNode) MAPPER.readTree(body);
final String idPropertyName = determineIdProperty(exchange);
final JsonNode idProperty = node.remove(idPropertyName);
if (idProperty == null) {
exchange.setException(
new SalesforceException("Missing option value for Id or " + SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, 404));
return;
}
final String idValue = idProperty.textValue();
if ("Id".equals(idPropertyName)) {
in.setHeader(SalesforceEndpointConfig.SOBJECT_ID, idValue);
} else {
in.setHeader(SalesforceEndpointConfig.SOBJECT_EXT_ID_VALUE, idValue);
}
// base fields are not allowed to be updated
clearBaseFields(node);
// update input json
in.setBody(MAPPER.writeValueAsString(node));
}
示例11: fromJson
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Object fromJson(JsonNode json) {
if (json.isTextual()) {
return json.textValue();
} else if (json.isNumber()) {
return json.numberValue();
} else if (json.isBoolean()) {
return json.booleanValue();
} else {
return null;
}
}
示例12: getValue
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private Object getValue(JsonNode node) {
if (node.isNumber()) {
return node.numberValue();
} else if (node.isTextual()) {
return node.textValue();
} else if (node.isBoolean()) {
return node.booleanValue();
} else if (node.isNull()) {
return null;
} else {
throw new IllegalArgumentException("Non-value JSON node got through value node filter");
}
}
示例13: convert
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Object convert(Schema schema, JsonNode value) {
return value.textValue();
}
示例14: matchesSafely
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public boolean matchesSafely(JsonNode jsonEthernet) {
// check source MAC
final JsonNode jsonSourceMacNode = jsonEthernet.get("srcMac");
if (ethernet.getSourceMAC() != null) {
final String jsonSourceMac = jsonSourceMacNode.textValue();
final String sourceMac = ethernet.getSourceMAC().toString();
if (!jsonSourceMac.equals(sourceMac)) {
reason = "source MAC " + ethernet.getSourceMAC().toString();
return false;
}
} else {
// source MAC not specified, JSON representation must be empty
if (jsonSourceMacNode != null) {
reason = "source mac should be null ";
return false;
}
}
// check destination MAC
final JsonNode jsonDestinationMacNode = jsonEthernet.get("destMac");
if (ethernet.getDestinationMAC() != null) {
final String jsonDestinationMac = jsonDestinationMacNode.textValue();
final String destinationMac = ethernet.getDestinationMAC().toString();
if (!jsonDestinationMac.equals(destinationMac)) {
reason = "destination MAC " + ethernet.getDestinationMAC().toString();
return false;
}
} else {
// destination MAC not specified, JSON representation must be empty
if (jsonDestinationMacNode != null) {
reason = "destination mac should be null ";
return false;
}
}
// check priority code
final short jsonPriorityCode = jsonEthernet.get("priorityCode").shortValue();
final short priorityCode = ethernet.getPriorityCode();
if (jsonPriorityCode != priorityCode) {
reason = "priority code " + Short.toString(ethernet.getPriorityCode());
return false;
}
// check vlanId
final short jsonVlanId = jsonEthernet.get("vlanId").shortValue();
final short vlanId = ethernet.getVlanID();
if (jsonVlanId != vlanId) {
reason = "vlan id " + Short.toString(ethernet.getVlanID());
return false;
}
// check etherType
final short jsonEtherType = jsonEthernet.get("etherType").shortValue();
final short etherType = ethernet.getEtherType();
if (jsonEtherType != etherType) {
reason = "etherType " + Short.toString(ethernet.getEtherType());
return false;
}
// check pad
final boolean jsonPad = jsonEthernet.get("pad").asBoolean();
final boolean pad = ethernet.isPad();
if (jsonPad != pad) {
reason = "pad " + Boolean.toString(ethernet.isPad());
return false;
}
return true;
}
示例15: getComponentId
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private String getComponentId(Map.Entry<String, JsonNode> stringJsonNodeEntry) {
String artifactId = stringJsonNodeEntry.getKey();
JsonNode version = stringJsonNodeEntry.getValue().get("version");
return version == null ? "" : artifactId + ":" + version.textValue();
}