本文整理了Java中com.fasterxml.jackson.databind.JsonNode.isObject()
方法的一些代码示例,展示了JsonNode.isObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isObject()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:isObject
暂无
代码示例来源:origin: apache/incubator-druid
private boolean isFlatList(JsonNode list)
{
for (JsonNode obj : list) {
if (obj.isObject() || obj.isArray()) {
return false;
}
}
return true;
}
}
代码示例来源:origin: Graylog2/graylog2-server
public Set<String> getClosedIndices(final Collection<String> indices) {
final JsonNode catIndices = catIndices(indices, "index", "status");
final ImmutableSet.Builder<String> closedIndices = ImmutableSet.builder();
for (JsonNode jsonElement : catIndices) {
if (jsonElement.isObject()) {
final String index = jsonElement.path("index").asText(null);
final String status = jsonElement.path("status").asText(null);
if (index != null && "close".equals(status)) {
closedIndices.add(index);
}
}
}
return closedIndices.build();
}
代码示例来源:origin: joelittlejohn/jsonschema2pojo
private ObjectNode arraySchema(JsonNode exampleArray) {
ObjectNode schema = this.objectMapper.createObjectNode();
schema.put("type", "array");
if (exampleArray.size() > 0) {
JsonNode exampleItem = exampleArray.get(0).isObject() ? mergeArrayItems(exampleArray) : exampleArray.get(0);
schema.set("items", schemaFromExample(exampleItem));
}
return schema;
}
代码示例来源:origin: twosigma/beakerx
@Override
public boolean canBeUsed(JsonNode n) {
return n.isObject() && (!n.has("type") || !parent.isKnownBeakerType(n.get("type").asText()));
}
代码示例来源:origin: aws/aws-sdk-java
policyNode = Jackson.jsonNodeOf(jsonString);
idNode = policyNode.get(JsonDocumentFields.POLICY_ID);
if (isNotNull(idNode)) {
policy.setId(idNode.asText());
statementsNode = policyNode.get(JsonDocumentFields.STATEMENT);
if (isNotNull(statementsNode)) {
if (statementsNode.isObject()) {
statements.add(statementOf(statementsNode));
} else if (statementsNode.isArray()) {
for (JsonNode statementNode : statementsNode) {
statements.add(statementOf(statementNode));
代码示例来源:origin: knowm/XChange
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (node.isTextual()) {
return node.textValue();
} else if (node.isObject()) {
JsonNode allNode = node.get("__all__");
if (allNode != null && allNode.isArray()) {
StringBuilder buf = new StringBuilder();
for (JsonNode msgNode : allNode) {
buf.append(msgNode.textValue());
buf.append(",");
}
return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString();
}
return node.toString();
}
return null;
}
}
代码示例来源:origin: Netflix/conductor
private Object extractBody(ClientResponse cr) {
String json = cr.getEntity(String.class);
logger.info(json);
try {
JsonNode node = om.readTree(json);
if (node.isArray()) {
return om.convertValue(node, listOfObj);
} else if (node.isObject()) {
return om.convertValue(node, mapOfObj);
} else if (node.isNumber()) {
return om.convertValue(node, Double.class);
} else {
return node.asText();
}
} catch (IOException jpe) {
logger.error(jpe.getMessage(), jpe);
return json;
}
}
代码示例来源:origin: stackoverflow.com
public static void printAll(JsonNode node) {
Iterator<String> fieldNames = node.getFieldNames();
while(fieldNames.hasNext()){
String fieldName = fieldNames.next();
JsonNode fieldValue = node.get(fieldName);
if (fieldValue.isObject()) {
System.out.println(fieldName + " :");
printAll(fieldValue);
} else {
String value = fieldValue.asText();
System.out.println(fieldName + " : " + value);
}
}
}
代码示例来源:origin: opensourceBIM/BIMserver
String propertySetName = entry.getKey();
JsonNode value = entry.getValue();
if (value.isObject()) {
ObjectNode set = (ObjectNode)value;
Iterator<Entry<String, JsonNode>> propertySetFields = set.fields();
queryPart.addProperty(propertySetName, propertyEntry.getKey(), propertyValue.asDouble());
} else if (propertyValue.getNodeType() == JsonNodeType.STRING) {
queryPart.addProperty(propertySetName, propertyEntry.getKey(), propertyValue.asText());
} else if (propertyValue.getNodeType() == JsonNodeType.NULL) {
queryPart.addProperty(propertySetName, propertyEntry.getKey(), null);
代码示例来源:origin: twosigma/beakerx
@Override
public boolean canBeUsed(JsonNode n) {
return n.isObject() && (!n.has("type") || !parent.isKnownBeakerType(n.get("type").asText()));
}
代码示例来源:origin: apache/avro
if (schema == null || schema.getType().equals(Schema.Type.STRING) ||
schema.getType().equals(Schema.Type.ENUM)) {
return jsonNode.asText();
} else if (schema.getType().equals(Schema.Type.BYTES)
|| schema.getType().equals(Schema.Type.FIXED)) {
return jsonNode.textValue().getBytes(StandardCharsets.ISO_8859_1);
} else if (jsonNode.isArray()) {
List l = new ArrayList();
for (JsonNode node : jsonNode) {
} else if (jsonNode.isObject()) {
Map m = new LinkedHashMap();
for (Iterator<String> it = jsonNode.fieldNames(); it.hasNext(); ) {
s = schema.getField(key).schema();
Object value = toObject(jsonNode.get(key), s);
m.put(key, value);
代码示例来源:origin: knowm/XChange
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (node.isTextual()) {
return node.textValue();
} else if (node.isObject()) {
JsonNode allNode = node.get("__all__");
if (allNode != null && allNode.isArray()) {
StringBuffer buf = new StringBuffer();
for (JsonNode msgNode : allNode) {
buf.append(msgNode.textValue());
buf.append(",");
}
return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString();
}
return node.toString();
}
return null;
}
}
代码示例来源:origin: rampatra/jbot
@JsonSetter("comment")
public void setComment(JsonNode jsonNode) {
if (jsonNode.isObject()) {
try {
this.comment = new ObjectMapper().treeToValue(jsonNode, Comment.class);
} catch (JsonProcessingException e) {
logger.error("Error deserializing json: ", e);
}
} else if (jsonNode.isTextual()) {
this.commentId = jsonNode.asText();
}
}
代码示例来源:origin: apache/incubator-druid
return charsetFix(val.asText());
if (val.isArray()) {
List<Object> newList = new ArrayList<>();
for (JsonNode entry : val) {
if (val.isObject()) {
Map<String, Object> newMap = new LinkedHashMap<>();
for (Iterator<Map.Entry<String, JsonNode>> it = val.fields(); it.hasNext(); ) {
代码示例来源:origin: knowm/XChange
@Override
public CoinMarketCapQuote deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);
if (node.isObject()) {
BigDecimal price = new BigDecimal(node.get("price").asDouble());
BigDecimal volume24h = new BigDecimal(node.get("volume_24h").asDouble());
BigDecimal marketCap = new BigDecimal(node.get("market_cap").asDouble());
// TODO use these to create CoinMarketCapHistoricalSpotPrice instances
BigDecimal pctChange1h = new BigDecimal(node.get("percent_change_1h").asDouble());
BigDecimal pctChange24h = new BigDecimal(node.get("percent_change_24h").asDouble());
BigDecimal pctChange7d = new BigDecimal(node.get("percent_change_7d").asDouble());
return new CoinMarketCapQuote(
price, volume24h, marketCap, pctChange1h, pctChange24h, pctChange7d);
}
return null;
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public Iterable<String> discoverRootFields(final JsonNode obj)
{
return FluentIterable.from(() -> obj.fields())
.filter(
entry -> {
final JsonNode val = entry.getValue();
return !(val.isObject() || val.isNull() || (val.isArray() && !isFlatList(val)));
}
)
.transform(Map.Entry::getKey);
}
代码示例来源:origin: twosigma/beakerx
@Override
public boolean canBeUsed(JsonNode n) {
return n.isObject() && (!n.has("type") || !parent.isKnownBeakerType(n.get("type").asText()));
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
JsonNode routingDefaultsNode = config.get("routingDefaults");
if (routingDefaultsNode != null) {
LOG.info("Loading default routing parameters from JSON:");
JsonNode timeout = config.get("timeout");
if (timeout != null) {
if (timeout.isNumber()) {
JsonNode timeouts = config.get("timeouts");
if (timeouts != null) {
if (timeouts.isArray() && timeouts.size() > 0) {
this.timeouts = new double[timeouts.size()];
int i = 0;
JsonNode boardTimes = config.get("boardTimes");
if (boardTimes != null && boardTimes.isObject()) {
graph.boardTimes = new EnumMap<>(TraverseMode.class);
for (TraverseMode mode : TraverseMode.values()) {
JsonNode alightTimes = config.get("alightTimes");
if (alightTimes != null && alightTimes.isObject()) {
graph.alightTimes = new EnumMap<>(TraverseMode.class);
for (TraverseMode mode : TraverseMode.values()) {
代码示例来源:origin: knowm/XChange
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (node.isTextual()) {
return node.textValue();
} else if (node.isObject()) {
JsonNode allNode = node.get("__all__");
if (allNode != null && allNode.isArray()) {
StringBuffer buf = new StringBuffer();
for (JsonNode msgNode : allNode) {
buf.append(msgNode.textValue());
buf.append(",");
}
return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString();
}
return node.toString();
}
return null;
}
}
代码示例来源:origin: rampatra/jbot
@JsonSetter("user")
public void setUser(JsonNode jsonNode) {
if (jsonNode.isObject()) {
try {
this.user = new ObjectMapper().treeToValue(jsonNode, User.class);
} catch (JsonProcessingException e) {
logger.error("Error deserializing json: ", e);
}
} else if (jsonNode.isTextual()) {
this.userId = jsonNode.asText();
}
}
内容来源于网络,如有侵权,请联系作者删除!