当前位置: 首页>>代码示例>>Java>>正文


Java JsonNode.textValue方法代码示例

本文整理汇总了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);
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:PropertyDao.java

示例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);
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:PropertyDao.java

示例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;
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:25,代码来源:MerlinProcess3.java

示例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();
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:34,代码来源:JsonUtil.java

示例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);
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:21,代码来源:Json.java

示例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(); } 
}
 
开发者ID:JohnChernoff,项目名称:BingoChess,代码行数:37,代码来源:BingoChessChallenge.java

示例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;
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:28,代码来源:JacksonMapper.java

示例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;
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:11,代码来源:PluginManager.java

示例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);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:16,代码来源:CommitMessageDtoDeserializer.java

示例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));
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:36,代码来源:AdaptObjectForUpdateProcessor.java

示例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;
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:13,代码来源:PrimitiveOverlay.java

示例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");
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:14,代码来源:BigParseTest.java

示例13: convert

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Object convert(Schema schema, JsonNode value) {
    return value.textValue();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:5,代码来源:JsonConverter.java

示例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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:72,代码来源:EthernetJsonMatcher.java

示例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();
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:6,代码来源:NpmScanManager.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.textValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。