本文整理了Java中elemental.json.Json.createArray()
方法的一些代码示例,展示了Json.createArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.createArray()
方法的具体详情如下:
包路径:elemental.json.Json
类名称:Json
方法名:createArray
暂无
代码示例来源:origin: com.vaadin/vaadin-server
private static JsonArray encodeArrayContents(Type componentType,
Object array, ConnectorTracker connectorTracker) {
JsonArray jsonArray = Json.createArray();
for (int i = 0; i < Array.getLength(array); i++) {
EncodeResult encodeResult = encode(Array.get(array, i), null,
componentType, connectorTracker);
jsonArray.set(i, encodeResult.getEncodedValue());
}
return jsonArray;
}
代码示例来源:origin: com.vaadin/vaadin-server
private static JsonArray encodeObjectMap(Type keyType, Type valueType,
Map<?, ?> map, ConnectorTracker connectorTracker) {
JsonArray keys = Json.createArray();
JsonArray values = Json.createArray();
for (Entry<?, ?> entry : map.entrySet()) {
EncodeResult encodedKey = encode(entry.getKey(), null, keyType,
connectorTracker);
EncodeResult encodedValue = encode(entry.getValue(), null,
valueType, connectorTracker);
keys.set(keys.length(), encodedKey.getEncodedValue());
values.set(values.length(), encodedValue.getEncodedValue());
}
JsonArray jsonMap = Json.createArray();
jsonMap.set(0, keys);
jsonMap.set(1, values);
return jsonMap;
}
代码示例来源:origin: com.vaadin/vaadin-server
private static JsonArray encodeCollection(Type targetType,
Collection<?> collection, ConnectorTracker connectorTracker) {
JsonArray jsonArray = Json.createArray();
for (Object o : collection) {
jsonArray.set(jsonArray.length(),
encodeChild(targetType, 0, o, connectorTracker));
}
return jsonArray;
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Sends given collection of data objects to the client-side.
*
* @param firstIndex
* first index of pushed data
* @param data
* data objects to send as an iterable
*/
protected void pushData(int firstIndex, List<T> data) {
JsonArray dataArray = Json.createArray();
int i = 0;
for (T item : data) {
dataArray.set(i++, getDataObject(item));
}
rpc.setData(firstIndex, dataArray);
handler.addActiveData(data.stream());
handler.cleanUp(data.stream());
}
代码示例来源: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
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/hummingbird-server
/**
* Clears the list of dependencies which should be sent to the client.
*/
public void clearPendingSendToClient() {
pendingSendToClient = Json.createArray();
}
代码示例来源:origin: com.vaadin/vaadin-server
JsonArray dataArray = Json.createArray();
int i = 0;
for (T data : updatedData) {
代码示例来源:origin: com.vaadin/vaadin-server
ui.getConnectorTracker().getDirtyVisibleConnectors());
JsonArray rpcCalls = Json.createArray();
for (ClientMethodInvocation invocation : pendingInvocations) {
JsonArray invocationJson = Json.createArray();
invocationJson.set(0,
invocation.getConnector().getConnectorId());
invocationJson.set(1, invocation.getInterfaceName());
invocationJson.set(2, invocation.getMethodName());
JsonArray paramJson = Json.createArray();
for (int i = 0; i < invocation
.getParameterTypes().length; ++i) {
代码示例来源:origin: com.vaadin/vaadin-server
for (ClientConnector connector : dirtyVisibleConnectors) {
String connectorId = connector.getConnectorId();
JsonArray children = Json.createArray();
代码示例来源:origin: com.googlecode.gwtquery/gwtquery
private <T> JsonArray listToJsonArray(Object... l) throws Throwable {
JsonArray ret = Json.createArray();
for (Object o : l) {
setValue(ret, null, null, o);
}
return ret;
}
代码示例来源:origin: com.vaadin/flow-server
private JsonArray filterUpdatableProperties(
Map<String, Boolean> allowedProperties) {
JsonArray array = Json.createArray();
int i = 0;
for (Entry<String, Boolean> entry : allowedProperties.entrySet()) {
if (entry.getValue()) {
array.set(i, entry.getKey());
i++;
}
}
return array;
}
代码示例来源:origin: com.vaadin/vaadin-checkbox-flow
private static <T> JsonArray modelToPresentation(CheckboxGroup<T> group,
Set<T> model) {
JsonArray array = Json.createArray();
if (model.isEmpty()) {
return array;
}
model.stream().map(group.keyMapper::key)
.forEach(key -> array.set(array.length(), key));
return array;
}
代码示例来源:origin: com.vaadin/flow-server
private static JsonArray toJsonArray(Object javaArray) {
int length = Array.getLength(javaArray);
JsonArray array = Json.createArray();
for (int i = 0; i < length; i++) {
array.set(i, toJson(Array.get(javaArray, i)));
}
return array;
}
代码示例来源:origin: com.vaadin/flow-server
private JsonArray getPath(org.jsoup.nodes.Element element,
org.jsoup.nodes.Element templateRoot) {
List<Integer> path = new ArrayList<>();
org.jsoup.nodes.Element current = element;
while (!current.equals(templateRoot)) {
org.jsoup.nodes.Element parent = current.parent();
path.add(indexOf(parent, current));
current = parent;
}
JsonArray array = Json.createArray();
for (int i = 0; i < path.size(); i++) {
array.set(i, path.get(path.size() - i - 1));
}
return array;
}
代码示例来源:origin: com.haulmont.cuba/cuba-web-widgets
public void showSuggestions(List<T> suggestions) {
final JsonArray jsonArray = Json.createArray();
for (int i = 0; i < suggestions.size() && i < suggestionsLimit; i++) {
jsonArray.set(i, getJsonObject(suggestions.get(i)));
}
getRpcProxy(CubaSuggestionFieldClientRpc.class).showSuggestions(jsonArray);
}
代码示例来源:origin: com.vaadin/flow-server
private JsonArray filterUnsetProperties(List<String> properties) {
JsonArray array = Json.createArray();
ElementPropertyMap map = getStateNode()
.getFeature(ElementPropertyMap.class);
int i = 0;
for (String property : properties) {
if (!map.hasProperty(property)) {
array.set(i, property);
i++;
}
}
return array;
}
代码示例来源: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/flow-server
/**
* Adds the performance timing data (used by TestBench 3) to the UIDL
* response.
*/
private JsonValue createPerformanceData(UI ui) {
JsonArray timings = Json.createArray();
timings.set(0, ui.getSession().getCumulativeRequestDuration());
timings.set(1, ui.getSession().getLastRequestDuration());
return timings;
}
代码示例来源:origin: com.vaadin/hummingbird-server
/**
* Adds the performance timing data (used by TestBench 3) to the UIDL
* response.
*/
private JsonValue createPerformanceData(UI ui) {
JsonArray timings = Json.createArray();
timings.set(0, ui.getSession().getCumulativeRequestDuration());
timings.set(1, ui.getSession().getLastRequestDuration());
return timings;
}
内容来源于网络,如有侵权,请联系作者删除!