本文整理了Java中elemental.json.JsonObject.get()
方法的一些代码示例,展示了JsonObject.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonObject.get()
方法的具体详情如下:
包路径:elemental.json.JsonObject
类名称:JsonObject
方法名:get
[英]Return the element (uncoerced) as a JsonValue.
[中]将元素(未编码)作为JsonValue返回。
代码示例来源:origin: com.vaadin/vaadin-server
private static boolean jsonObjectEquals(JsonObject a, JsonObject b) {
String[] keys = a.keys();
if (keys.length != b.keys().length) {
return false;
}
for (String key : keys) {
JsonValue value = b.get(key);
if (value == null || !jsonEquals(a.get(key), value)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.vaadin/vaadin-server
public RpcRequest(String jsonString, VaadinRequest request) {
json = JsonUtil.parse(jsonString);
JsonValue token = json.get(ApplicationConstants.CSRF_TOKEN);
if (token == null) {
csrfToken = ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE;
代码示例来源:origin: com.vaadin/vaadin-upload-flow
private String getStringObject(String propertyName, String object,
String subName) {
String result = null;
JsonObject json = (JsonObject) getElement()
.getPropertyRaw(propertyName);
if (json != null && json.hasKey(object)
&& !(json.get(object) instanceof JsonNull)) {
json = json.getObject(object);
if (json != null && json.hasKey(subName)
&& !(json.get(subName) instanceof JsonNull)) {
result = json.getString(subName);
}
}
return result;
}
代码示例来源:origin: com.vaadin/vaadin-upload-flow
private String getStringObject(String propertyName, String subName) {
String result = null;
JsonObject json = (JsonObject) getElement()
.getPropertyRaw(propertyName);
if (json != null && json.hasKey(subName)
&& !(json.get(subName) instanceof JsonNull)) {
result = json.getString(subName);
}
return result;
}
代码示例来源:origin: org.eclipse.che.core/che-core-ide-app
/**
* Allows to get IDE state for current workspace from user preferences.
*
* @return IDE state of current workspace or {@code null} when this one is not found
*/
@Nullable
JsonObject getAppState() {
JsonObject allWsState = getAllWorkspacesState();
if (allWsState == null) {
return null;
}
String wsId = appContext.getWorkspace().getId();
JsonObject workspaceSettings = allWsState.getObject(wsId);
return workspaceSettings != null ? workspaceSettings.get(WORKSPACE) : null;
}
代码示例来源:origin: com.vaadin/hummingbird-server
@Override
protected void handleNode(StateNode node, JsonObject invocationJson) {
assert invocationJson.hasKey(JsonConstants.RPC_PROPERTY);
assert invocationJson.hasKey(JsonConstants.RPC_PROPERTY_VALUE);
String property = invocationJson.getString(JsonConstants.RPC_PROPERTY);
Serializable value = JsonCodec.decodeWithoutTypeInfo(
invocationJson.get(JsonConstants.RPC_PROPERTY_VALUE));
node.getFeature(ElementPropertyMap.class).setProperty(property, value,
false);
}
代码示例来源:origin: com.vaadin/vaadin-server
private static Map<Object, Object> decodeStringMap(Type valueType,
JsonObject jsonMap, ConnectorTracker connectorTracker) {
Map<Object, Object> map = new HashMap<>();
for (String key : jsonMap.keys()) {
Object value = decodeInternalOrCustomType(valueType,
jsonMap.get(key), connectorTracker);
if (valueType == UidlValue.class) {
value = ((UidlValue) value).getValue();
}
map.put(key, value);
}
return map;
}
代码示例来源:origin: com.vaadin/hummingbird-server
@Override
public void handle(UI ui, JsonObject invocationJson) {
History history = ui.getPage().getHistory();
HistoryStateChangeHandler historyStateChangeHandler = history
.getHistoryStateChangeHandler();
if (historyStateChangeHandler != null) {
JsonValue state = invocationJson
.get(JsonConstants.RPC_NAVIGATION_STATE);
String location = invocationJson
.getString(JsonConstants.RPC_NAVIGATION_LOCATION);
HistoryStateChangeEvent event = new HistoryStateChangeEvent(history,
state, location);
historyStateChangeHandler.onHistoryStateChange(event);
}
}
代码示例来源:origin: com.vaadin/vaadin-server
private static Map<Object, Object> decodeConnectorMap(Type valueType,
JsonObject jsonMap, ConnectorTracker connectorTracker) {
Map<Object, Object> map = new HashMap<>();
for (String key : jsonMap.keys()) {
Object value = decodeInternalOrCustomType(valueType,
jsonMap.get(key), connectorTracker);
if (valueType == UidlValue.class) {
value = ((UidlValue) value).getValue();
}
map.put(connectorTracker.getConnector(key), value);
}
return map;
}
代码示例来源:origin: com.vaadin/flow-server
@Override
public Optional<Runnable> handle(UI ui, JsonObject invocationJson) {
History history = ui.getPage().getHistory();
HistoryStateChangeHandler historyStateChangeHandler = history
.getHistoryStateChangeHandler();
if (historyStateChangeHandler != null) {
JsonValue state = invocationJson
.get(JsonConstants.RPC_NAVIGATION_STATE);
String location = invocationJson
.getString(JsonConstants.RPC_NAVIGATION_LOCATION);
boolean triggeredByLink = invocationJson
.hasKey(JsonConstants.RPC_NAVIGATION_ROUTERLINK);
NavigationTrigger trigger = triggeredByLink
? NavigationTrigger.ROUTER_LINK
: NavigationTrigger.HISTORY;
HistoryStateChangeEvent event = new HistoryStateChangeEvent(history,
state, new Location(location), trigger);
historyStateChangeHandler.onHistoryStateChange(event);
}
return Optional.empty();
}
代码示例来源:origin: com.vaadin/vaadin-server
private static Object decodeObject(Type targetType,
JsonObject serializedObject, ConnectorTracker connectorTracker) {
Class<?> targetClass = getClassForType(targetType);
try {
Object decodedObject = ReflectTools.createInstance(targetClass);
for (BeanProperty property : getProperties(targetClass)) {
String fieldName = property.getName();
JsonValue encodedFieldValue = serializedObject.get(fieldName);
Type fieldType = property.getType();
Object decodedFieldValue = decodeInternalOrCustomType(fieldType,
encodedFieldValue, connectorTracker);
property.setValue(decodedObject, decodedFieldValue);
}
return decodedObject;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.vaadin/vaadin-server
fieldReference = referenceValue.get(fieldName);
if (fieldReference instanceof JsonNull) {
fieldReference = null;
代码示例来源:origin: com.vaadin/flow-server
private static DebouncePhase extractPhase(JsonObject eventData) {
JsonValue jsonValue = eventData.get(JsonConstants.EVENT_DATA_PHASE);
if (jsonValue == null) {
return DebouncePhase.LEADING;
} else {
return DebouncePhase.forIdentifier(jsonValue.asString());
}
}
代码示例来源:origin: com.vaadin/flow-server
private static boolean jsonObjectEquals(JsonObject a, JsonObject b) {
assert a != null;
assert b != null;
if (a == b) {
return true;
}
String[] keys = a.keys();
if (keys.length != b.keys().length) {
return false;
}
for (String key : keys) {
JsonValue value = b.get(key);
if (value == null || !jsonEquals(a.get(key), value)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.vaadin/hummingbird-server
private static boolean jsonObjectEquals(JsonObject a, JsonObject b) {
assert a != null;
assert b != null;
if (a == b) {
return true;
}
String[] keys = a.keys();
if (keys.length != b.keys().length) {
return false;
}
for (String key : keys) {
JsonValue value = b.get(key);
if (value == null || !jsonEquals(a.get(key), value)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.haulmont.cuba/cuba-web-toolkit
@Override
public ClientAction deserialize(Type type, JsonValue jsonValue, ApplicationConnection connection) {
ClientAction clientAction = new ClientAction();
JsonObject clientActionObject = (JsonObject) jsonValue;
clientAction.setCaption(clientActionObject.get("caption").asString());
clientAction.setActionId(clientActionObject.get("actionId").asString());
return clientAction;
}
代码示例来源:origin: com.vaadin/flow-server
private Optional<Runnable> enqueuePropertyUpdate(StateNode node,
JsonObject invocationJson, Class<? extends NodeFeature> feature,
String property) {
Serializable value = JsonCodec.decodeWithoutTypeInfo(
invocationJson.get(JsonConstants.RPC_PROPERTY_VALUE));
value = tryConvert(value, node);
return Optional.of(node.getFeature(ElementPropertyMap.class)
.deferredUpdateFromClient(property, value));
}
代码示例来源:origin: com.vaadin/flow-data
@Override
public void generateData(T item, JsonObject data) {
JsonValue value = JsonSerializer.toJson(item);
if (value instanceof JsonObject) {
JsonObject object = (JsonObject) value;
for (String key : object.keys()) {
data.put(key, (JsonValue) object.get(key));
}
} else {
data.put("value", value);
}
}
代码示例来源:origin: com.googlecode.gwtquery/gwtquery
private String param(JsonObject o) {
String ret = "";
for (String k : o.keys()) {
ret += ret.isEmpty() ? "" : "&";
JsonValue v = o.get(k);
if (v instanceof JsonArray) {
for (int i = 0, l = ((JsonArray) v).length(); i < l; i++) {
ret += i > 0 ? "&" : "";
JsonValue e = ((JsonArray) v).get(i);
ret += k + "[]=" + e.toJson();
}
} else {
if (v != null && !(v instanceof JsonNull)) {
ret += k + "=" + v.toJson();
}
}
}
return ret;
}
代码示例来源:origin: com.vaadin/vaadin-rich-text-editor-flow
/**
* Sets the internationalization properties for this component.
*
* @param i18n
* the internationalized properties, not <code>null</code>
*/
public void setI18n(RichTextEditorI18n i18n) {
Objects.requireNonNull(i18n,
"The I18N properties object should not be null");
this.i18n = i18n;
runBeforeClientResponse(ui -> {
if (i18n == this.i18n) {
JsonObject i18nObject = (JsonObject) JsonSerializer
.toJson(this.i18n);
for (String key : i18nObject.keys()) {
ui.getPage().executeJavaScript(
"$0.set('i18n." + key + "', $1)", getElement(),
i18nObject.get(key));
}
}
});
}
内容来源于网络,如有侵权,请联系作者删除!