本文整理汇总了Java中com.couchbase.client.java.document.json.JsonObject.get方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.get方法的具体用法?Java JsonObject.get怎么用?Java JsonObject.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.couchbase.client.java.document.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EventEntry
import com.couchbase.client.java.document.json.JsonObject; //导入方法依赖的package包/类
/**
* Creates a new EventEntry based on data provided by Couchbase.
*
* @param jsonObject Mongo object that contains data to represent an
* EventEntry
*/
EventEntry(JsonObject jsonObject) {
this.aggregateIdentifier = (String) jsonObject.get(AGGREGATE_IDENTIFIER_PROPERTY);
this.sequenceNumber = ((Number) jsonObject.get(SEQUENCE_NUMBER_PROPERTY)).longValue();
this.serializedPayload = jsonObject.get(SERIALIZED_PAYLOAD_PROPERTY);
this.timeStamp = (String) jsonObject.get(TIME_STAMP_PROPERTY);
this.aggregateType = (String) jsonObject.get(AGGREGATE_TYPE_PROPERTY);
this.payloadType = (String) jsonObject.get(PAYLOAD_TYPE_PROPERTY);
this.payloadRevision = (String) jsonObject.get(PAYLOAD_REVISION_PROPERTY);
this.serializedMetaData = jsonObject.get(META_DATA_PROPERTY);
this.eventIdentifier = (String) jsonObject.get(EVENT_IDENTIFIER_PROPERTY);
}
示例2: processRecord
import com.couchbase.client.java.document.json.JsonObject; //导入方法依赖的package包/类
private static void processRecord(NoSqlTreeNode parentNode, JsonObject record) {
for (String key : record.getNames()) {
Object value = record.get(key);
NoSqlTreeNode currentNode = new NoSqlTreeNode(CouchbaseKeyValueDescriptor.createDescriptor(key, value));
if (value instanceof JsonArray) {
processRecordListValues(currentNode, (JsonArray) value);
} else if (value instanceof JsonObject) {
processRecord(currentNode, (JsonObject) value);
}
parentNode.add(currentNode);
}
}
示例3: toEntity
import com.couchbase.client.java.document.json.JsonObject; //导入方法依赖的package包/类
/**
*
* @param targetClass an entity class with getter/setter method or <code>Map.class</code>
* @param jsonObject
* @return
*/
public static <T> T toEntity(final Class<T> targetClass, final JsonObject jsonObject) {
checkTargetClass(targetClass);
if (jsonObject == null) {
return null;
}
if (Map.class.isAssignableFrom(targetClass)) {
final Map<String, Object> m = jsonObject.toMap();
if (targetClass.isAssignableFrom(m.getClass())) {
return (T) m;
} else {
final Map<String, Object> result = (Map<String, Object>) N.newInstance(targetClass);
result.putAll(m);
return (T) result;
}
} else {
final T entity = N.newInstance(targetClass);
final List<String> columnNameList = new ArrayList<>(jsonObject.getNames());
Method propSetMethod = null;
Class<?> parameterType = null;
Object propValue = null;
for (String propName : columnNameList) {
propSetMethod = ClassUtil.getPropSetMethod(targetClass, propName);
if (propSetMethod == null) {
continue;
}
parameterType = propSetMethod.getParameterTypes()[0];
propValue = jsonObject.get(propName);
if (propValue != null && !parameterType.isAssignableFrom(propValue.getClass())) {
if (propValue instanceof JsonObject) {
if (parameterType.isAssignableFrom(Map.class) || N.isEntity(parameterType)) {
ClassUtil.setPropValue(entity, propSetMethod, toEntity(parameterType, (JsonObject) propValue));
} else {
ClassUtil.setPropValue(entity, propSetMethod, N.valueOf(parameterType, N.stringOf(toEntity(Map.class, (JsonObject) propValue))));
}
} else if (propValue instanceof JsonArray) {
if (parameterType.isAssignableFrom(List.class)) {
ClassUtil.setPropValue(entity, propSetMethod, ((JsonArray) propValue).toList());
} else {
ClassUtil.setPropValue(entity, propSetMethod, N.valueOf(parameterType, N.stringOf(((JsonArray) propValue).toList())));
}
} else {
ClassUtil.setPropValue(entity, propSetMethod, propValue);
}
} else {
ClassUtil.setPropValue(entity, propSetMethod, propValue);
}
}
if (N.isDirtyMarker(entity.getClass())) {
((DirtyMarker) entity).markDirty(false);
}
return entity;
}
}