当前位置: 首页>>代码示例>>Java>>正文


Java JsonObject类代码示例

本文整理汇总了Java中elemental.json.JsonObject的典型用法代码示例。如果您正苦于以下问题:Java JsonObject类的具体用法?Java JsonObject怎么用?Java JsonObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonObject类属于elemental.json包,在下文中一共展示了JsonObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendUploadResponse

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
protected void sendUploadResponse(VaadinRequest request, VaadinResponse response,
                                  String fileName, long contentLength) throws IOException {
    JsonArray json = Json.createArray();
    JsonObject fileInfo = Json.createObject();
    fileInfo.put("name", fileName);
    fileInfo.put("size", contentLength);

    // just fake addresses and parameters
    fileInfo.put("url", fileName);
    fileInfo.put("thumbnail_url", fileName);
    fileInfo.put("delete_url", fileName);
    fileInfo.put("delete_type", "POST");
    json.set(0, fileInfo);

    PrintWriter writer = response.getWriter();
    writer.write(json.toJson());
    writer.close();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:CubaVaadinServletService.java

示例2: buildJson

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
public JsonValue buildJson() {
    JsonObject map = Json.createObject();
    putNotNull(map, "customClassOption", customClassOption);
    putNotNull(map, "customClassOptionText", customClassOptionText);
    putNotNull(map, "linkValidation", linkValidation);
    putNotNull(map, "placeholderText", placeholderText);
    putNotNull(map, "targetCheckbox", targetCheckbox);
    putNotNull(map, "targetCheckboxText", targetCheckboxText);
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:12,代码来源:Anchor.java

示例3: generateData

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
public void generateData(Object itemId, Item item, JsonObject jsonRow) {

    JsonObject jsonData = jsonRow.getObject("d");

    for (String key : jsonData.keys()) {

        if (getColumn(key).getRenderer() == this) {
            // 2: VERY IMPORTANT get the component from the connector tracker !!!
            //    if you use a GeneratedPropertyContainer and call get Value you will
            //    get a different component

            if (jsonData.get(key) != Json.createNull()) {
                Component current = lookupComponent(jsonData, key);
                trackComponent(itemId, current);
            }
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:ComponentRenderer.java

示例4: addClickHandler

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
protected HandlerRegistration addClickHandler(
        RendererClickHandler<JsonObject> handler) {
    return getRenderer().addClickHandler(handler);
}
 
开发者ID:phansson,项目名称:vaadin-clickabletextrenderer-v8,代码行数:6,代码来源:ClickableTextRendererConnector.java

示例5: showRoute

import elemental.json.JsonObject; //导入依赖的package包/类
private void showRoute(String start, String end, boolean debounce) {
    JsonObject properties = Json.createObject();
    properties.put("start", start);
    properties.put("end", end);
    properties.put("debounce", debounce);
    getElement().callFunction("setProperties", properties);
}
 
开发者ID:vaadin,项目名称:trippy,代码行数:8,代码来源:TripMap.java

示例6: run

import elemental.json.JsonObject; //导入依赖的package包/类
public List<Workout> run() {
	List<Workout> workouts = new ArrayList<>();
	Stream.of(38, 39, 40, 41).map(i -> "data/week-" + i + ".json").map(this::readFile).map(Json::parse)
			.map(json -> json.getArray("workouts")).forEach(jsonArray -> {
				for (int i = 0; i < jsonArray.length(); ++i) {
					JsonObject workout = jsonArray.get(i);
					LocalDate date = LocalDate.parse(workout.getString("date"),
							DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
					Sport sport = Sport.valueOf(workout.getString("sport").toUpperCase());
					Integer duration = (int) workout.getNumber("duration");
					Integer calories = (int) workout.getNumber("calories");
					workouts.add(new Workout(date, sport, duration, calories));
				}
			});
	return workouts;
}
 
开发者ID:amahdy,项目名称:java-pwa,代码行数:17,代码来源:WorkoutDataReader.java

示例7: buildJson

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
public JsonValue buildJson() {
    JsonObject map = Json.createObject();
    if (icon != null) {
        String contentFA = icon.getHtml();
        if (iconText != null) {
            contentFA += iconText;
        }
        putNotNull(map, "contentFA", contentFA);
    }
    putNotNull(map, "contentDefault", iconFallback);
    if (customTranslation) {
        putNotNull(map, "aria", aria);
    } else {
        // get buildin translations
        putNotNull(map, "aria", toolbarBuilder.getOptionsBuilder().getTranslation(aria));
    }
    putNotNull(map, "name", name);
    putNotNull(map, "action", action == null ? name : action);
    putNotNull(map, "tagNames", tagNames);
    putNotNull(map, "style", style);
    putNotNull(map, "useQueryState", useQueryState);
    putNotNull(map, "classList", classList);
    putNotNull(map, "attrs", attrs);
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:27,代码来源:ToolbarButton.java

示例8: generateData

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
public void generateData(Object itemId, Item item, JsonObject rowData) {
    HierarchyData hierarchyData = new HierarchyData();

    // calculate depth
    int depth = 0;
    if (getContainer() instanceof Measurable) {
        depth = ((Measurable) getContainer()).getDepth(itemId);  // Measurable
    } else {
        Object id = itemId;
        while (!getContainer().isRoot(id)) {
            id = getContainer().getParent(id);
            depth++;
        }
    }
    hierarchyData.setDepth(depth);

    // set collapsed state
    if (getContainer() instanceof Collapsible) {
        hierarchyData.setCollapsed(((Collapsible) getContainer()).isCollapsed(itemId));  // Collapsible
    }

    // set leaf state
    hierarchyData.setLeaf(!getContainer().hasChildren(itemId));  // Hierarchical

    // set index of parent node
    hierarchyData.setParentIndex(getContainer()
            .indexOfId(getContainer().getParent(itemId))); // Indexed (indexOfId) and Hierarchical (getParent)

    // add hierarchy information to row as metadata
    rowData.put(GridState.JSONKEY_ROWDESCRIPTION,
            JsonCodec.encode(hierarchyData, null, HierarchyData.class, getUI().getConnectorTracker())
                    .getEncodedValue());
}
 
开发者ID:vaadin,项目名称:tree-grid,代码行数:35,代码来源:HierarchyDataGenerator.java

示例9: putNotNull

import elemental.json.JsonObject; //导入依赖的package包/类
protected void putNotNull(JsonObject obj, String key, Map<String, String> map) {
    if (map != null) {
        JsonObject mapObj = Json.createObject();
        for (Entry<String, String> entry : map.entrySet()) {
            mapObj.put(entry.getKey(), entry.getValue());
        }
        obj.put(key, mapObj);
    }
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:10,代码来源:AbstractBuilder.java

示例10: putNotNull

import elemental.json.JsonObject; //导入依赖的package包/类
public static void putNotNull(JsonObject obj, String key, Map<String, String> map) {
    if (map != null) {
        JsonObject mapObj = Json.createObject();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            mapObj.put(entry.getKey(), entry.getValue());
        }
        obj.put(key, mapObj);
    }
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:10,代码来源:JUtils.java

示例11: buildJson

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
public JsonValue buildJson() {
    JsonArray array = Json.createArray();
    for (KeyboardCommand c : commands) {
        JsonObject map = Json.createObject();
        putNotNull(map, "command", c.command);
        putNotNull(map, "key", c.key);
        putNotNull(map, "meta", c.meta);
        putNotNull(map, "shift", c.shift);
        putNotNull(map, "alt", c.alt);
        array.set(array.length(), map);
    }
    return array;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:15,代码来源:KeyboardCommands.java

示例12: buildJson

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
public JsonObject buildJson() {
    JsonObject map = Json.createObject();
    JUtils.putNotNull(map, "type", type);
    List<Double> data = getData();
    JUtils.putNotNullNumbers(map, "data", data);
    JUtils.putNotNull(map, "label", label);
    JUtils.putNotNull(map, "hidden", hidden);
    if (randomBackgroundColors && data != null) {
        List<String> bgColors = new ArrayList<>();
        for (int i = 0; i < data.size(); i++) {
            bgColors.add(ColorUtils.randomColor(0.7));
        }
        backgroundColor = bgColors;
    }
    JUtils.putNotNullStringListOrSingle(map, "backgroundColor", backgroundColor);
    JUtils.putNotNullStringListOrSingle(map, "borderColor", borderColor);
    JUtils.putNotNullIntListOrSingle(map, "borderWidth", borderWidth);
    JUtils.putNotNullStringListOrSingle(map, "hoverBackgroundColor", hoverBackgroundColor);
    JUtils.putNotNullStringListOrSingle(map, "hoverBorderColor", hoverBorderColor);
    JUtils.putNotNullIntListOrSingle(map, "hoverBorderWidth", hoverBorderWidth);
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:24,代码来源:PieDataset.java

示例13: updateCurrentPage

import elemental.json.JsonObject; //导入依赖的package包/类
private void updateCurrentPage() {
	// try to find selected item if requested
	if (getState().scrollToSelectedItem && getState().pageLength > 0 && getWidget().currentPage < 0
			&& getWidget().selectedOptionKeys != null) {
		// search for the item with the selected key
		getWidget().currentPage = 0;
		for (int i = 0; i < getDataSource().size(); ++i) {
			JsonObject row = getDataSource().getRow(i);
			if (row != null) {
				String key = getRowKey(row);
				if (getWidget().selectedOptionKeys.contains(key)) {
					getWidget().currentPage = i / getState().pageLength;
					break;
				}
			}
		}
	} else if (getWidget().currentPage < 0) {
		getWidget().currentPage = 0;
	}
}
 
开发者ID:bonprix,项目名称:vaadin-combobox-multiselect,代码行数:21,代码来源:ComboBoxMultiselectConnector.java

示例14: init

import elemental.json.JsonObject; //导入依赖的package包/类
/**
 * Initialize the ComboBoxMultiselect with default settings and register client to server RPC implementation.
 */
private void init() {
    registerRpc(this.rpc);
    registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));

    addDataGenerator((final T data, final JsonObject jsonObject) -> {
        String caption = getItemCaptionGenerator().apply(data);
        if (caption == null) {
            caption = "";
        }
        jsonObject.put(DataCommunicatorConstants.NAME, caption);
        final String style = this.itemStyleGenerator.apply(data);
        if (style != null) {
            jsonObject.put(ComboBoxMultiselectConstants.STYLE, style);
        }
        final Resource icon = getItemIconGenerator().apply(data);
        if (icon != null) {
            final String iconUrl = ResourceReference.create(icon, ComboBoxMultiselect.this, null)
                    .getURL();
            jsonObject.put(ComboBoxMultiselectConstants.ICON, iconUrl);
        }
    });
}
 
开发者ID:bonprix,项目名称:vaadin-combobox-multiselect,代码行数:26,代码来源:ComboBoxMultiselect.java

示例15: buildJson

import elemental.json.JsonObject; //导入依赖的package包/类
@Override
public JsonObject buildJson() {
    JsonObject map = Json.createObject();
    JUtils.putNotNull(map, "type", "radar");
    // data
    if (data != null) {
        JUtils.putNotNull(map, "data", data.buildJson());
    }
    // options
    if (options != null) {
        JUtils.putNotNull(map, "options", options.buildJson());
    }
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:15,代码来源:RadarChartConfig.java


注:本文中的elemental.json.JsonObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。