本文整理了Java中elemental.json.Json.createObject()
方法的一些代码示例,展示了Json.createObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.createObject()
方法的具体详情如下:
包路径:elemental.json.Json
类名称:Json
方法名:createObject
暂无
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Creates the JsonObject for given data object. This method calls all data
* generators for it.
*
* @param data
* data object to be made into a json object
* @return json object representing the data object
*/
protected JsonObject getDataObject(T data) {
JsonObject dataObject = Json.createObject();
for (DataGenerator<T> generator : generators) {
generator.generateData(data, dataObject);
}
return dataObject;
}
代码示例来源:origin: com.vaadin/vaadin-server
private static JsonObject encodeStringMap(Type valueType, Map<?, ?> map,
ConnectorTracker connectorTracker) {
JsonObject jsonMap = Json.createObject();
for (Entry<?, ?> entry : map.entrySet()) {
String key = (String) entry.getKey();
EncodeResult encodedValue = encode(entry.getValue(), null,
valueType, connectorTracker);
jsonMap.put(key, encodedValue.getEncodedValue());
}
return jsonMap;
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Drag data generator. Appends drag data to row data json if generator
* function(s) are set by the user of this extension.
*
* @param item
* Row item for data generation.
* @param jsonObject
* Row data in json format.
*/
private void generateDragData(T item, JsonObject jsonObject) {
JsonObject generatedValues = Json.createObject();
generatorFunctions.forEach((type, generator) -> generatedValues
.put(type, generator.apply(item)));
jsonObject.put(GridDragSourceState.JSONKEY_DRAG_DATA, generatedValues);
}
代码示例来源:origin: com.vaadin/vaadin-server
private static JsonObject encodeConnectorMap(Type valueType, Map<?, ?> map,
ConnectorTracker connectorTracker) {
JsonObject jsonMap = Json.createObject();
for (Entry<?, ?> entry : map.entrySet()) {
ClientConnector key = (ClientConnector) entry.getKey();
if (LegacyCommunicationManager.isConnectorVisibleToClient(key)) {
EncodeResult encodedValue = encode(entry.getValue(), null,
valueType, connectorTracker);
jsonMap.put(key.getConnectorId(),
encodedValue.getEncodedValue());
}
}
return jsonMap;
}
代码示例来源:origin: com.vaadin/vaadin-server
private void updateResolutions() {
final T currentDate = getValue();
Map<String, Integer> resolutions = getState().resolutions;
resolutions.clear();
// Only paint variables for the resolution and up, e.g. Resolution DAY
// paints DAY,MONTH,YEAR
for (R resolution : getResolutionsHigherOrEqualTo(getResolution())) {
String resolutionName = resolution.name();
Integer value = getValuePart(currentDate, resolution);
resolutions.put(resolutionName, value);
Integer defaultValuePart = getValuePart(defaultValue, resolution);
resolutions.put("default-" + resolutionName, defaultValuePart);
}
updateDiffstate("resolutions", Json.createObject());
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Gets a data object with the given key from the given JsonObject. If
* there is no object with the key, this method creates a new
* JsonObject.
*
* @param jsonObject
* the json object
* @param key
* the key where the desired data object is stored
* @return data object for the given key
*/
private JsonObject getDataObject(JsonObject jsonObject, String key) {
if (!jsonObject.hasKey(key)) {
jsonObject.put(key, Json.createObject());
}
return jsonObject.getObject(key);
}
代码示例来源:origin: com.vaadin/vaadin-server
String returnString = "";
try {
JsonObject appError = Json.createObject();
putValueOrJsonNull(appError, "caption", caption);
putValueOrJsonNull(appError, "url", url);
putValueOrJsonNull(appError, "details", details);
JsonObject meta = Json.createObject();
meta.put("appError", appError);
JsonObject json = Json.createObject();
json.put("changes", Json.createObject());
json.put("resources", Json.createObject());
json.put("locales", Json.createObject());
json.put("meta", meta);
json.put(ApplicationConstants.SERVER_SYNC_ID, -1);
代码示例来源:origin: com.vaadin/vaadin-server
private JsonArray toJsonArray(List<Dependency> list) {
JsonArray result = Json.createArray();
for (int i = 0; i < list.size(); i++) {
JsonObject dep = Json.createObject();
Dependency dependency = list.get(i);
dep.put("type", dependency.getType().name());
dep.put("url", dependency.getUrl());
result.set(i, dep);
}
return result;
}
代码示例来源:origin: com.vaadin/vaadin-server
JsonObject sharedStates = Json.createObject();
for (ClientConnector connector : dirtyVisibleConnectors) {
代码示例来源:origin: com.vaadin/vaadin-server
public String asJson() {
JsonArray uris = Json.createArray();
for (String uri : sourceUris) {
uris.set(uris.length(), uri);
}
JsonObject object = Json.createObject();
object.put("version", Version.getFullVersion());
object.put("timestamp", Long.toString(timestamp));
object.put("uris", uris);
object.put("css", css);
return object.toJson();
}
代码示例来源:origin: com.vaadin/vaadin-server
&& !isDifferentValue(v)) {
updateDiffstate("resolutions",
Json.createObject());
doSetValue(v);
代码示例来源:origin: com.vaadin/vaadin-server
private static EncodeResult encodeObject(Object value, Class<?> valueType,
JsonObject referenceValue, ConnectorTracker connectorTracker) {
JsonObject encoded = Json.createObject();
JsonObject diff = Json.createObject();
代码示例来源:origin: com.haulmont.cuba/cuba-web-toolkit
@Override
public JsonValue serialize(ClientAction value, ApplicationConnection connection) {
// serialization to json not needed for this type
return Json.createObject();
}
}
代码示例来源:origin: com.vaadin/vaadin-server
.getConnectorTracker().getDirtyVisibleConnectors();
JsonObject connectorTypes = Json.createObject();
for (ClientConnector connector : dirtyVisibleConnectors) {
String connectorType = target.getTag(connector);
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public boolean synchronizedHandleRequest(VaadinSession session,
VaadinRequest request, VaadinResponse response) throws IOException {
try {
assert UI.getCurrent() == null;
// Update browser information from the request
session.getBrowser().updateRequestDetails(request);
UI uI = getBrowserDetailsUI(request, session);
session.getCommunicationManager().repaintAll(uI);
JsonObject params = Json.createObject();
params.put(UIConstants.UI_ID_PARAMETER, uI.getUIId());
String initialUIDL = getInitialUidl(request, uI);
params.put("uidl", initialUIDL);
return commitJsonResponse(request, response,
JsonUtil.stringify(params));
} catch (JsonException e) {
throw new IOException("Error producing initial UIDL", e);
}
}
代码示例来源:origin: com.vaadin/vaadin-server
.getConnectorTracker().getDirtyVisibleConnectors();
JsonObject hierarchyInfo = Json.createObject();
for (ClientConnector connector : dirtyVisibleConnectors) {
String connectorId = connector.getConnectorId();
代码示例来源:origin: com.vaadin/vaadin-server
updateDiffstate("selectedItemKey", Json.createObject());
代码示例来源:origin: com.vaadin/vaadin-server
@Override
public void generateData(T item, JsonObject jsonObject) {
JsonObject hierarchyData = Json.createObject();
int depth = getDepth(item);
if (depth >= 0) {
hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_DEPTH,
depth);
}
boolean isLeaf = !getDataProvider().hasChildren(item);
if (isLeaf) {
hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_LEAF,
true);
} else {
hierarchyData.put(
HierarchicalDataCommunicatorConstants.ROW_COLLAPSED,
!isExpanded(item));
hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_LEAF,
false);
hierarchyData.put(
HierarchicalDataCommunicatorConstants.ROW_COLLAPSE_ALLOWED,
getItemCollapseAllowedProvider().test(item));
}
// add hierarchy information to row as metadata
jsonObject.put(
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION,
hierarchyData);
}
代码示例来源:origin: com.vaadin/vaadin-server
VaadinService vaadinService = request.getService();
JsonObject appConfig = Json.createObject();
JsonObject versionInfo = Json.createObject();
versionInfo.put("vaadinVersion", Version.getFullVersion());
String atmosphereVersion = AtmospherePushConnection
if (systemMessages != null) {
JsonObject comErrMsg = Json.createObject();
putValueOrNull(comErrMsg, "caption",
systemMessages.getCommunicationErrorCaption());
JsonObject authErrMsg = Json.createObject();
putValueOrNull(authErrMsg, "caption",
systemMessages.getAuthenticationErrorCaption());
JsonObject sessExpMsg = Json.createObject();
putValueOrNull(sessExpMsg, "caption",
systemMessages.getSessionExpiredCaption());
代码示例来源:origin: org.eclipse.che.core/che-core-ide-app
private JsonObject storeEditors(EditorMultiPartStackState splitStacks) {
JsonObject result = Json.createObject();
if (splitStacks.getEditorPartStack() != null) {
result.put("FILES", storeEditors(splitStacks.getEditorPartStack()));
} else {
result.put("DIRECTION", splitStacks.getDirection().toString());
result.put("SPLIT_FIRST", storeEditors(splitStacks.getSplitFirst()));
result.put("SPLIT_SECOND", storeEditors(splitStacks.getSplitSecond()));
result.put("SIZE", splitStacks.getSize());
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!