本文整理汇总了Java中com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT属性的典型用法代码示例。如果您正苦于以下问题:Java JsonNodeType.OBJECT属性的具体用法?Java JsonNodeType.OBJECT怎么用?Java JsonNodeType.OBJECT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.fasterxml.jackson.databind.node.JsonNodeType
的用法示例。
在下文中一共展示了JsonNodeType.OBJECT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseResponse
private List<FieldValues> parseResponse(final JsonNode response) {
if (response == null || response.get("fields") == null) {
throw new RuntimeException("Failed to parse JSON");
}
final JsonNode fieldsNode = response.get("fields");
if (fieldsNode.getNodeType() == JsonNodeType.OBJECT || fieldsNode.getNodeType() == JsonNodeType.ARRAY) {
final List<FieldValues> output = new ArrayList<>();
for (final JsonNode node : fieldsNode) {
try {
final FieldValues fieldValues = objectMapper.treeToValue(node, FieldValues.class);
output.add(fieldValues);
} catch (final JsonProcessingException e) {
throw new RuntimeException("Failed to parse JSON", e);
}
}
return output;
} else {
throw new RuntimeException("Failed to parse JSON");
}
}
示例2: listSites
/**
* List of all not-empty rooms
* @param user the id of the person requesting the list, or null if unauthenticated
* @param map
* @return List of all sites, possibly filtered by owner and/or name. Will not return null.
*/
public List<JsonNode> listSites(ResourceAccessPolicy accessPolicy, String owner, String name) {
Log.log(Level.FINER, this, "List all rooms");
List<JsonNode> result = sites.listSites(nullEmpty(owner), nullEmpty(name));
//we have to step through any results to remove the connectionDetails blocks.
for(JsonNode j : result){
JsonNode ownerNode = j.get("owner");
if(ownerNode!=null && ownerNode.getNodeType().equals(JsonNodeType.STRING)){
String ownerNodeString = ownerNode.textValue();
//remove connectionDetailsBlocks unless requested by owner or the system id
if( stripSensitiveData(accessPolicy, ownerNodeString)){
JsonNode info = j.get("info");
if(info.getNodeType() == JsonNodeType.OBJECT){
ObjectNode infoObj = (ObjectNode)info;
if(infoObj.has("connectionDetails")){
infoObj.remove("connectionDetails");
}
}
}
}
}
return result;
}
示例3: decodeAttributes
private Map<String, String> decodeAttributes(JsonNode tree, String name) {
final JsonNode n = tree.get(name);
if (n == null) {
return EMPTY_ATTRIBUTES;
}
if (n.getNodeType() != JsonNodeType.OBJECT) {
return EMPTY_ATTRIBUTES;
}
final Map<String, String> attributes = Maps.newHashMap();
final Iterator<Map.Entry<String, JsonNode>> iter = n.fields();
while (iter.hasNext()) {
final Map.Entry<String, JsonNode> e = iter.next();
attributes.put(e.getKey(), e.getValue().asText());
}
return attributes;
}
示例4: setText
public void setText(JsonNode jn) {
if (isComposed) {
if(jn.getNodeType() == JsonNodeType.OBJECT) {
com.fasterxml.jackson.databind.node.ObjectNode on = (ObjectNode) jn;
for(JComponent jc : children) {
if(jc instanceof JTextComponent) {
JsonNode jn2 = on.get(jc.getName());
// TODO nested components
((JTextComponent) jc).setText(jn2.asText());
}
}
} else {
JOptionPane.showMessageDialog(null, "Unsupported Type", "Composed type value: " + jn, JOptionPane.ERROR_MESSAGE);
}
} else {
((JTextComponent) component).setText(jn.asText());
}
}
示例5: parseJSON
private void parseJSON() throws SchemaConfigurationError {
try {
ObjectNode fields = (ObjectNode) root.get("fields");
Iterator<Map.Entry<String, JsonNode>> iterator = fields.fields();
while (iterator.hasNext()) {
Map.Entry<String, JsonNode> entry = iterator.next();
FieldIndex index = buildField(entry.getKey(), entry.getValue());
schema.addFieldIndex(index.getName(), index);
}
JsonNode persistence = root.get("persistence");
//as a default set DummyQueryStorage. Only if persistence options are provided overwrite it
schema.setQueryStorage(new DummyQueryStorage());
if (persistence != null && persistence.getNodeType() == JsonNodeType.OBJECT) {
//if persistence key doesn't exist there is no persistence
JsonNode file = persistence.get("file");
if (file != null && file.getNodeType() == JsonNodeType.STRING) {
schema.setQueryStorage(new MapDBStore(new File(schemaDirectory, file.asText())));
} else {
LOGGER.error("unable to get file name for query storage. Continuing with no persistence!");
}
}
} catch (Exception e) {
throw new SchemaConfigurationError("Could not parse JSON tree", e);
}
schema.init();
}
示例6: generateDiffs
private static void generateDiffs(final DiffProcessor processor, final JsonPointer pointer,
final JsonNode source, final JsonNode target) {
if (EQUIVALENCE.equivalent(source, target)) {
return;
}
final JsonNodeType sourceType = source.getNodeType();
final JsonNodeType targetType = target.getNodeType();
/*
* Node types differ: generate a replacement operation.
*/
if (sourceType != targetType) {
processor.valueReplaced(pointer, source, target);
return;
}
/*
* If we reach this point, it means that both nodes are the same type,
* but are not equivalent.
*
* If this is not a container, generate a replace operation.
*/
if (!source.isContainerNode()) {
processor.valueReplaced(pointer, source, target);
return;
}
/*
* If we reach this point, both nodes are either objects or arrays;
* delegate.
*/
if (sourceType == JsonNodeType.OBJECT) {
generateObjectDiffs(processor, pointer, (ObjectNode) source, (ObjectNode) target);
} else {
// array
generateArrayDiffs(processor, pointer, (ArrayNode) source, (ArrayNode) target);
}
}
示例7: createSchemaByJsonNode
private static ObjectNode createSchemaByJsonNode(JsonNode node) {
ObjectNode resultNodeNew = mapper.getNodeFactory().objectNode();
if (node.getNodeType() == JsonNodeType.OBJECT) {
ObjectNode objResult = leafNodes(node);
resultNodeNew.put(TYPE, OBJECT);
resultNodeNew.set(PROPERTIES, objResult);
} else if (node.getNodeType() == JsonNodeType.ARRAY) {
ObjectNode items = identifyAndProcessArrayNode(node);
resultNodeNew = items;
}
return resultNodeNew;
}
示例8: createModelByJsonNode
private void createModelByJsonNode(JsonNode node, String apiName, ModelBuilder rootModelBuilder){
if (node.getNodeType() == JsonNodeType.OBJECT) {
createObjectModel(node, rootModelBuilder, apiName);
models.put(apiName, rootModelBuilder);
} else if (node.getNodeType() == JsonNodeType.ARRAY) {
ArrayPropertyBuilder arrayPropertyBuilder = rootModelBuilder.withArrayProperty(apiName);
createArrayModel(node, arrayPropertyBuilder, apiName + "-item");
models.put(apiName, rootModelBuilder);
}
}
示例9: createObjectModel
private void createObjectModel(JsonNode node, ModelBuilder modelBuilder, String apiName) {
Iterator<String> fieldNames = node.fieldNames();
while (fieldNames.hasNext()) {
String field = fieldNames.next();
JsonNode leafNode = node.get(field);
if (leafNode.getNodeType() == JsonNodeType.NUMBER) {
if (leafNode.isInt() || leafNode.isLong()) {
modelBuilder.withIntegerPropertyNamed(field).withExample(leafNode.asLong());
} else if (leafNode.isFloat() || leafNode.isDouble()) {
modelBuilder.withNumberPropertyNamed(field).withExample(leafNode.asDouble());
}
} else if (leafNode.getNodeType() == JsonNodeType.BOOLEAN) {
modelBuilder.withBooleanPropertyNamed(field).withExample(leafNode.asBoolean());
} else if (leafNode.getNodeType() == JsonNodeType.STRING) {
modelBuilder.withStringPropertyNamed(field).withExample(leafNode.asText());
} else if (leafNode.getNodeType() == JsonNodeType.OBJECT) {
String refName = apiName+"-"+field;
modelBuilder.withReferencePropertyNamed(field).withReferenceTo(refName);
ModelBuilder objModelBuilder = new ModelBuilder();
createObjectModel(leafNode, objModelBuilder, refName);
models.put(refName, objModelBuilder);
}else if(leafNode.getNodeType() == JsonNodeType.ARRAY){
createArrayModel(leafNode, modelBuilder.withArrayProperty(field), apiName+"-"+field);
}
}
}
示例10: deserializeExtension
private Extension deserializeExtension(JsonParser jp, JsonNode rootNode, String urn) throws IOException {
if (urn == null || urn.isEmpty()) {
throw new IllegalStateException("The URN cannot be null or empty");
}
if (rootNode.getNodeType() != JsonNodeType.OBJECT) {
throw new JsonMappingException(jp, "Extension is of wrong JSON type");
}
Extension.Builder extensionBuilder = new Extension.Builder(urn);
Iterator<Map.Entry<String, JsonNode>> fieldIterator = rootNode.fields();
while (fieldIterator.hasNext()) {
Map.Entry<String, JsonNode> entry = fieldIterator.next();
switch (entry.getValue().getNodeType()) {
case BOOLEAN:
Boolean boolValue = ExtensionFieldType.BOOLEAN.fromString(entry.getValue().asText());
extensionBuilder.setField(entry.getKey(), boolValue);
break;
case STRING:
String stringValue = ExtensionFieldType.STRING.fromString(entry.getValue().asText());
extensionBuilder.setField(entry.getKey(), stringValue);
break;
case NUMBER:
String numberValueAsString = entry.getValue().asText();
if (numberValueAsString.contains(".")) {
BigDecimal decimalValue = ExtensionFieldType.DECIMAL.fromString(numberValueAsString);
extensionBuilder.setField(entry.getKey(), decimalValue);
} else {
BigInteger integerValue = ExtensionFieldType.INTEGER.fromString(numberValueAsString);
extensionBuilder.setField(entry.getKey(), integerValue);
}
break;
default:
throw new IllegalArgumentException("JSON type not supported: " + entry.getValue().getNodeType());
}
}
return extensionBuilder.build();
}
示例11: unmarshall
/**
* Update the content of this object with a JSON structure.<br/>
* NB: selectableColumns are never updated
*
* @param json
* the json node to unmarshall
*/
private void unmarshall(JsonNode json) throws FilterConfigException {
JsonNode currentPageNode = json.get(JSON_CURRENT_PAGE_FIELD);
if (currentPageNode != null && currentPageNode.getNodeType() == JsonNodeType.NUMBER) {
setCurrentPage(((Long) currentPageNode.asLong()).intValue());
if (log.isDebugEnabled()) {
log.debug("Unmarshalled page number : " + getCurrentPage());
}
}
JsonNode userConfigAsJson = json.get(JSON_USER_CONFIG_FIELD);
if (userConfigAsJson != null && userConfigAsJson.getNodeType() == JsonNodeType.OBJECT) {
Iterator<String> fieldNames = userConfigAsJson.fieldNames();
while (fieldNames.hasNext()) {
String columnId = fieldNames.next();
if (getUserColumnConfigurations().containsKey(columnId)) {
UserColumnConfiguration userColumnConfiguration = getUserColumnConfigurations().get(columnId);
JsonNode userColumnConfigurationAsJson = userConfigAsJson.get(columnId);
if (log.isDebugEnabled()) {
log.debug("Unmarshalled json : " + userColumnConfigurationAsJson);
}
userColumnConfiguration.unmarshall(getSelectableColumns().get(columnId), userColumnConfigurationAsJson);
} else {
if (log.isDebugEnabled()) {
log.debug("Unknown column : " + columnId);
}
}
}
}
if (json.has(JSON_SELECTED_ROWS_FIELD) && json.get(JSON_SELECTED_ROWS_FIELD).isArray()) {
this.selectedRows = new ArrayList<>();
for (JsonNode node : json.get(JSON_SELECTED_ROWS_FIELD)) {
this.selectedRows.add(node.asText());
}
}
}
示例12: isJsonSchemaType
public static boolean isJsonSchemaType(JsonNode type) {
boolean isJsonSchema = false;
// TODO use JSON schema parser
if (type != null && type.getNodeType() == JsonNodeType.OBJECT) {
JsonNode value = type.findValue("type");
if(value != null) {
isJsonSchema = JSON_SCHEMA_PRIMITIVE_TYPES.contains(value.asText());
}
}
return isJsonSchema;
}
示例13: parseNode
protected ClauseNode parseNode(JsonNode node) throws MalformedQueryException {
if (node.getNodeType() == JsonNodeType.OBJECT) {
if (isCondition(node)) {
return handleCondition((ObjectNode) node);
} else {
return parseClauseNode(node);
}
}
return null;
}
示例14: getAnalyzer
private Analyzer getAnalyzer(JsonNode options) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
String analyzerName = "de.danielbasedow.prospecter.core.analysis.LuceneStandardAnalyzer";
if (options != null && options.getNodeType() == JsonNodeType.OBJECT) {
JsonNode analyzerNode = options.get("analyzer");
if (analyzerNode != null && analyzerNode.getNodeType() == JsonNodeType.STRING) {
analyzerName = analyzerNode.asText();
}
}
LOGGER.info("using analyzer " + analyzerName);
Class class_ = Class.forName(analyzerName);
Method factory = class_.getMethod("make", JsonNode.class);
return (Analyzer) factory.invoke(null, options);
}
示例15: deserializeExtension
public Extension deserializeExtension(JsonNode rootNode, String urn) throws IOException {
if (urn == null || urn.isEmpty()) {
throw new IllegalStateException("The URN cannot be null or empty");
}
if (rootNode.getNodeType() != JsonNodeType.OBJECT) {
throw new JsonMappingException("Extension is of wrong JSON type");
}
Extension.Builder extensionBuilder = new Extension.Builder(urn);
Iterator<Map.Entry<String, JsonNode>> fieldIterator = rootNode.fields();
while (fieldIterator.hasNext()) {
Map.Entry<String, JsonNode> entry = fieldIterator.next();
switch (entry.getValue().getNodeType()) {
case BOOLEAN:
Boolean boolValue = ExtensionFieldType.BOOLEAN.fromString(entry.getValue().asText());
extensionBuilder.setField(entry.getKey(), boolValue);
break;
case STRING:
String stringValue = ExtensionFieldType.STRING.fromString(entry.getValue().asText());
extensionBuilder.setField(entry.getKey(), stringValue);
break;
case NUMBER:
String numberValueAsString = entry.getValue().asText();
if (numberValueAsString.contains(".")) {
BigDecimal decimalValue = ExtensionFieldType.DECIMAL.fromString(numberValueAsString);
extensionBuilder.setField(entry.getKey(), decimalValue);
} else {
BigInteger integerValue = ExtensionFieldType.INTEGER.fromString(numberValueAsString);
extensionBuilder.setField(entry.getKey(), integerValue);
}
break;
default:
throw new IllegalArgumentException("JSON type not supported: " + entry.getValue().getNodeType());
}
}
return extensionBuilder.build();
}