本文整理了Java中elemental.json.Json.create()
方法的一些代码示例,展示了Json.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.create()
方法的具体详情如下:
包路径:elemental.json.Json
类名称:Json
方法名:create
暂无
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public JsonValue serialize(Date value, ConnectorTracker connectorTracker) {
return Json.create(value.getTime());
}
代码示例来源:origin: com.vaadin/vaadin-testbench-core
private JsonValue createJsonValue(Object value) {
if (value == null) {
return Json.createNull();
} else if (value instanceof String) {
return Json.create((String) value);
} else if (value instanceof Number) {
return Json.create(((Number) value).doubleValue());
} else if (value instanceof Boolean) {
return Json.create((Boolean) value);
} else {
throw new IllegalArgumentException(
"Type of property is unsupported: "
+ value.getClass().getName());
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-web-widgets
private JsonObject getJsonObject(T suggestion) {
final JsonObject object = Json.createObject();
//noinspection unchecked
object.put(SUGGESTION_ID, Json.create(keyMapper.key(suggestion)));
String caption = textViewConverter.apply(suggestion);
object.put(SUGGESTION_CAPTION, Json.create(caption));
if (optionsStyleProvider != null) {
String styleName = optionsStyleProvider.apply(suggestion);
object.put(SUGGESTION_STYLE_NAME, Json.create(styleName));
}
return object;
}
代码示例来源:origin: jreznot/electron-java-app
private void callElectronUiApi(String[] args) {
JsonArray paramsArray = Json.createArray();
int i = 0;
for (String arg : args) {
paramsArray.set(i, Json.create(arg));
i++;
}
getPage().getJavaScript().execute("callElectronUiApi(" + paramsArray.toJson() + ")");
}
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public JsonValue encode(Object value) {
if (value == null) {
return super.encode(null);
} else {
return Json.create(value.toString());
}
}
代码示例来源:origin: com.vaadin/flow-server
private static JsonValue encodeNode(Node<?> node) {
StateNode stateNode = node.getNode();
if (stateNode.isAttached()) {
return wrapComplexValue(NODE_TYPE, Json.create(stateNode.getId()));
} else {
return Json.createNull();
}
}
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public void setText(String text, int cursorPosition) {
updateDiffstate("text", Json.create(text));
lastKnownCursorPosition = cursorPosition;
setValue(text, true);
}
}
代码示例来源:origin: com.vaadin/hummingbird-server
private static JsonValue encodeElement(Element element) {
StateNode node = element.getNode();
if (node.isAttached()) {
return wrapComplexValue(ELEMENT_TYPE, Json.create(node.getId()));
} else {
return Json.createNull();
}
}
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public void disableOnClick() throws RuntimeException {
setEnabled(false);
// Makes sure the enabled=false state is noticed at once - otherwise
// a following setEnabled(true) call might have no effect. see
// ticket #10030
updateDiffstate("enabled", Json.create(false));
}
};
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public JsonValue encode(Component value) {
return value != null ? Json.create(value.getConnectorId()) : null;
}
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public void setText(String text) {
updateDiffstate("value", Json.create(text));
if (!setValue(text, true)) {
// The value was not updated, this could happen if the field has
// been set to readonly on the server and the client does not
// know about it yet. Must re-send the correct state back.
markAsDirty();
}
}
}
代码示例来源:origin: com.vaadin/vaadin-server
toReturn = Json.create((String) value);
} else if (value instanceof Boolean) {
toReturn = Json.create((Boolean) value);
} else if (value instanceof Number) {
toReturn = Json.create(((Number) value).doubleValue());
} else if (value instanceof Character) {
toReturn = Json.create(Character.toString((Character) value));
} else if (value instanceof Collection) {
toReturn = encodeCollection(valueType, (Collection<?>) value,
toReturn = Json.create(((Connector) value).getConnectorId());
} else if (value instanceof Enum) {
toReturn = Json.create(((Enum<?>) value).name());
} else if (CUSTOM_SERIALIZERS.containsKey(value.getClass())) {
toReturn = serializeJson(value, connectorTracker);
代码示例来源:origin: com.vaadin/flow-server
@Override
public JsonValue toJson() {
return Json.create(type.getSimpleName());
}
代码示例来源:origin: com.vaadin/flow-server
private static JsonArray wrapComplexValue(int typeId, JsonValue value) {
return JsonUtils.createArray(Json.create(typeId), value);
}
代码示例来源:origin: com.vaadin/hummingbird-server
private static JsonArray wrapComplexValue(int typeId, JsonValue value) {
return JsonUtil.createArray(Json.create(typeId), value);
}
代码示例来源:origin: com.vaadin/flow-server
private static JsonArray encodeExecuteJavaScript(
JavaScriptInvocation executeJavaScript) {
Stream<JsonValue> parametersStream = executeJavaScript.getParameters()
.stream().map(JsonCodec::encodeWithTypeInfo);
// [argument1, argument2, ..., script]
return Stream
.concat(parametersStream,
Stream.of(
Json.create(executeJavaScript.getExpression())))
.collect(JsonUtils.asArray());
}
代码示例来源:origin: com.vaadin/hummingbird-server
private static JsonArray encodeExecuteJavaScript(
JavaScriptInvocation executeJavaScript) {
Stream<JsonValue> parametersStream = executeJavaScript.getParameters()
.stream().map(JsonCodec::encodeWithTypeInfo);
// [argument1, argument2, ..., script]
return Stream
.concat(parametersStream,
Stream.of(
Json.create(executeJavaScript.getExpression())))
.collect(JsonUtil.asArray());
}
代码示例来源:origin: com.vaadin/hummingbird-server
@Override
protected void populateJson(JsonObject json) {
json.put(JsonConstants.CHANGE_FEATURE,
Json.create(NodeFeatureRegistry.getId(feature)));
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-web-widgets
@Override
public void setText(String text, int cursorPosition) {
updateDiffstate("text", Json.create(text));
LocalTime value = parseValue(text);
setValue(value, true);
}
}
代码示例来源:origin: com.vaadin/flow-server
@Override
protected void populateJson(JsonObject json, ConstantPool constantPool) {
json.put(JsonConstants.CHANGE_FEATURE,
Json.create(NodeFeatureRegistry.getId(feature)));
}
}
内容来源于网络,如有侵权,请联系作者删除!