本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.has方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.has方法的具体用法?Java JsonNode.has怎么用?Java JsonNode.has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JsonNode
的用法示例。
在下文中一共展示了JsonNode.has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assignDB
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static void assignDB(LineageNodeLite node) {
List<Map<String, Object>> rows = null;
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("urn", node.urn);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());
rows = namedParameterJdbcTemplate.queryForList(GET_DATA_ATTR, parameters);
// node only knows id, level, and urn, assign all other attributes
for (Map<String, Object> row : rows) {
JsonNode prop = Json.parse((String) row.get("properties"));
node.description = (prop.has("description")) ? prop.get("description").asText() : "null";
node.jdbc_url = (prop.has("jdbc_url")) ? prop.get("jdbc_url").asText() : "null";
node.db_code = (prop.has("db_code")) ? prop.get("db_code").asText() : "null";
// check wh_property for a user specified color, use some generic defaults if nothing found
//node.color = getColor(node.urn, node.node_type);
// set things to show up in tooltip
node._sort_list.add("db_code");
//node._sort_list.add("last_modified");
}
}
示例2: fromJson
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Create instance of the config from json string.
*
* @param jsonString json to process
* @return class instance
*/
public static ApplicationConfig fromJson(String jsonString) {
ApplicationConfig config = new ApplicationConfig();
try {
JsonNode json = new ObjectMapper().readTree(jsonString);
config.setContentConfig(ContentConfig.fromJson(json));
// store identifier is optional
if (json.has(JsonKeys.STORE_PACKAGE_IDENTIFIER)) {
config.setStoreIdentifier(json.get(JsonKeys.STORE_PACKAGE_IDENTIFIER).asText());
} else {
config.setStoreIdentifier("");
}
config.jsonString = jsonString;
} catch (Exception e) {
Log.d("CHCP", "Failed to convert json string into application config" , e);
config = null;
}
return config;
}
示例3: toConnectData
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public SchemaAndValue toConnectData(String topic, byte[] value) {
JsonNode jsonValue;
try {
jsonValue = deserializer.deserialize(topic, value);
} catch (SerializationException e) {
throw new DataException("Converting byte[] to Kafka Connect data failed due to serialization error: ", e);
}
if (enableSchemas && (jsonValue == null || !jsonValue.isObject() || jsonValue.size() != 2 || !jsonValue.has("schema") || !jsonValue.has("payload")))
throw new DataException("JsonConverter with schemas.enable requires \"schema\" and \"payload\" fields and may not contain additional fields." +
" If you are trying to deserialize plain JSON data, set schemas.enable=false in your converter configuration.");
// The deserialized data should either be an envelope object containing the schema and the payload or the schema
// was stripped during serialization and we need to fill in an all-encompassing schema.
if (!enableSchemas) {
ObjectNode envelope = JsonNodeFactory.instance.objectNode();
envelope.set("schema", null);
envelope.set("payload", jsonValue);
jsonValue = envelope;
}
return jsonToConnect(jsonValue);
}
示例4: apply
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {
if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()
&& (node.has("minLength") || node.has("maxLength"))) {
JAnnotationUse annotation = field.annotate(Size.class);
if (node.has("minLength")) {
annotation.param("min", node.get("minLength").asInt());
}
if (node.has("maxLength")) {
annotation.param("max", node.get("maxLength").asInt());
}
}
return field;
}
示例5: getIntegerBaseType
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Get IntegerBaseType by the type value of JsonNode which contains the
* constraints.
* @param type the type value of JsonNode
* @return IntegerBaseType
*/
private static IntegerBaseType getIntegerBaseType(JsonNode type) {
int min = Integer.MIN_VALUE;
int max = Integer.MAX_VALUE;
Set<Integer> enums = Sets.newHashSet();
JsonNode node = type.get("minInteger");
if (node != null) {
min = node.asInt();
}
node = type.get("maxInteger");
if (node != null) {
max = node.asInt();
}
if (type.has("enum")) {
JsonNode anEnum = type.get("enum").get(1);
for (JsonNode n : anEnum) {
enums.add(n.asInt());
}
}
return new IntegerBaseType(min, max, enums);
}
示例6: langFilterSTR
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private String langFilterSTR(JsonNode field) {
final String PATTERN = "FILTER (lang(%s) = \"%s\") . ";
String nodeVar = varSTR(field.get("nodeId").asText());
JsonNode args = field.get("args");
String langPattern = (args.has("lang")) ? String.format(PATTERN, nodeVar, args.get("lang").asText()) : "";
return langPattern;
}
示例7: getFieldName
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Get name of the field generated from property.
*
* @param propertyName
* @param node
* @return
*/
public String getFieldName(String propertyName, JsonNode node) {
if (node != null && node.has("javaName")) {
propertyName = node.get("javaName").textValue();
}
return propertyName;
}
示例8: getFirstChildNameValue
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static Optional<String> getFirstChildNameValue(JsonNode json, String columnName) {
if (json.has(columnName)) {
JsonNode array = json.get(columnName);
if (array.has(0)) {
JsonNode child = array.get(0);
if (child.has("name")) {
return Optional.of(child.get("name").asText());
}
}
}
return Optional.empty();
}
示例9: limitOffsetSTR
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private String limitOffsetSTR(JsonNode jsonQuery) {
JsonNode args = jsonQuery.get("args");
String limitSTR = "";
String offsetSTR = "";
if (args!=null) {
if (args.has("limit")) limitSTR = limitSTR(args.get("limit").asInt());
if (args.has("offset")) offsetSTR = offsetSTR(args.get("offset").asInt());
}
return limitSTR + offsetSTR;
}
示例10: fixJson
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
protected JsonNode fixJson(JsonNode json) {
if (json.isMissingNode()) {
json = jsonObject();
}
if (!json.has("paths")) {
((ObjectNode) json).putObject("paths");
}
return json;
}
示例11: computeUnchangedObject
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static void computeUnchangedObject(final Map<JsonPointer, JsonNode> ret, final JsonPointer pointer,
final JsonNode source, final JsonNode target) {
final Iterator<String> sourceFields = source.fieldNames();
while (sourceFields.hasNext()) {
final String name = sourceFields.next();
if (!target.has(name)) {
continue;
}
computeUnchanged(ret, pointer.append(JsonPointer.valueOf('/' + name)),
source.get(name), target.get(name));
}
}
示例12: parseErrorCodeFromContents
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Attempt to parse the error code from the response content. Returns null if information is not
* present in the content. Codes are expected to be in the form <b>"typeName"</b> or
* <b>"prefix#typeName"</b> Examples : "AccessDeniedException",
* "software.amazon.awssdk.dynamodb.v20111205#ProvisionedThroughputExceededException"
*/
private String parseErrorCodeFromContents(JsonNode jsonContents) {
if (jsonContents == null || !jsonContents.has(errorCodeFieldName)) {
return null;
}
String code = jsonContents.findValue(errorCodeFieldName).asText();
int separator = code.lastIndexOf("#");
return code.substring(separator + 1);
}
示例13: updateMeetingStatus
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private void updateMeetingStatus(JsonNode updateBody, Meeting existingMeeting) {
if (updateBody.has("meetingStatus")) {
String value = updateBody.get("meetingStatus").textValue();
if (StringUtils.isEmpty(value)) {
throw new OSoonException("모임 상태 값을 반드시 입력해야 합니다.");
}
Meeting.MeetingStatus meetingStatus = Meeting.MeetingStatus.valueOf(value);
existingMeeting.setMeetingStatus(meetingStatus);
}
}
示例14: configureSeviceAttribute
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private void configureSeviceAttribute (
ServiceAttributes attribute,
JsonNode definitionNode,
StringBuffer resultsBuffer ) {
String attributeText = attribute.value;
if ( definitionNode.has( attributeText ) ) {
attributeLoad( attribute, definitionNode, resultsBuffer );
} else {
attributeMissingMessage( attribute, resultsBuffer );
}
}
示例15: canBeUsed
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public boolean canBeUsed(JsonNode n) {
return n.has("type") && n.get("type").asText().equals("CyclingOutputContainerLayoutManager");
}
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:5,代码来源:CyclingOutputContainerLayoutManagerDeserializer.java