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


Java Json类代码示例

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


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

示例1: sendUploadResponse

import elemental.json.Json; //导入依赖的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.Json; //导入依赖的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.Json; //导入依赖的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: create

import elemental.json.Json; //导入依赖的package包/类
@Override
public Slob create(@Nullable String snapshot) throws InvalidSnapshot {
  if (snapshot == null) {
    return new RealtimeSlob(Json.createArray());
  } else {
    try {
      return new RealtimeSlob(Json.instance().parse(snapshot));
    } catch (JsonException e) {
      throw new InvalidSnapshot(e);
    }
  }
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:13,代码来源:RealtimeSlobAdapter.java

示例5: deserializeOps

import elemental.json.Json; //导入依赖的package包/类
private List<RealtimeOperation> deserializeOps(List<Delta<String>> changes) throws DeltaRejected {
  List<RealtimeOperation> ops = new ArrayList<RealtimeOperation>();
  for (Delta<String> delta : changes) {
    RealtimeOperation op;
    try {
      JsonValue serialized = Json.instance().parse(delta.getPayload());
      op =
          transformer.createOperation(delta.getSession().userId, delta.getSession().sessionId,
              serialized);
    } catch (JsonException e) {
      throw new DeltaRejected(e);
    }
    ops.add(op);
  }
  return ops;
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:17,代码来源:RealtimeSlobAdapter.java

示例6: showRoute

import elemental.json.Json; //导入依赖的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

示例7: run

import elemental.json.Json; //导入依赖的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

示例8: buildJson

import elemental.json.Json; //导入依赖的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

示例9: putNotNull

import elemental.json.Json; //导入依赖的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: buildJson

import elemental.json.Json; //导入依赖的package包/类
@Override
public JsonValue buildJson() {
    JsonObject map = Json.createObject();
    putNotNull(map, "allowMultiParagraphSelection", allowMultiParagraphSelection);
    if (buttons != null) {
        JsonArray btnList = Json.createArray();
        for (ToolbarButtonBuilder tbb : buttons) {
            btnList.set(btnList.length(), tbb.buildJson());
        }
        map.put("buttons", btnList);
    }
    putNotNull(map, "diffLeft", diffLeft);
    putNotNull(map, "diffTop", diffLeft);
    putNotNull(map, "firstButtonClass", firstButtonClass);
    putNotNull(map, "lastButtonClass", lastButtonClass);
    putNotNull(map, "standardizeSelectionStart", standardizeSelectionStart);
    putNotNull(map, "static", staticToolbar);
    // TODO relativeContainer // Toolbar is appended relative to a given DOM-Node instead of appending it to the body and position it absolute.
    //      map.put("relativeContainer", null);
    putNotNull(map, "align", align);
    putNotNull(map, "sticky", sticky);
    putNotNull(map, "stickyTopOffset", stickyTopOffset);
    putNotNull(map, "updateOnEmptySelection", updateOnEmptySelection);
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:26,代码来源:Toolbar.java

示例11: buildJson

import elemental.json.Json; //导入依赖的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: socketSend

import elemental.json.Json; //导入依赖的package包/类
public static <I> void socketSend(WebSocket socket, String url, I model, ObjectMapper<I> inMapper,
		JsonObject headers) {
	JsonObject object = Json.createObject();
	object.put("url", url);
	object.put("body", in(model, inMapper));
	object.put("headers", headers);
	socket.send(object.toJson());
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:9,代码来源:Pojofy.java

示例13: getJsonObject

import elemental.json.Json; //导入依赖的package包/类
private JsonObject getJsonObject(Object 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;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:CubaSuggestionField.java

示例14: buildJson

import elemental.json.Json; //导入依赖的package包/类
@Override
public JsonObject buildJson() {
    JsonObject map = Json.createObject();
    JUtils.putNotNull(map, "display", display);
    if (position != null) {
        JUtils.putNotNull(map, "position", position.name().toLowerCase());
    }
    JUtils.putNotNull(map, "text", text);
    JUtils.putNotNull(map, "fullWidth", fullWidth);
    JUtils.putNotNull(map, "fontSize", fontSize);
    JUtils.putNotNull(map, "fontFamily", fontFamily);
    JUtils.putNotNull(map, "fontColor", fontColor);
    JUtils.putNotNull(map, "fontStyle", fontStyle);
    JUtils.putNotNull(map, "padding", padding);
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:17,代码来源:Title.java

示例15: buildJson

import elemental.json.Json; //导入依赖的package包/类
@Override
public JsonObject buildJson() {
    JsonObject map = Json.createObject();
    JUtils.putNotNull(map, "tension", tension);
    JUtils.putNotNull(map, "backgroundColor", backgroundColor);
    JUtils.putNotNull(map, "borderColor", borderColor);
    JUtils.putNotNull(map, "borderWidth", borderWidth);
    if (borderCapStyle != null) {
        JUtils.putNotNull(map, "borderCapStyle", borderCapStyle.name().toLowerCase());
    }
    JUtils.putNotNullIntList(map, "borderDash", borderDash);
    JUtils.putNotNull(map, "borderDashOffset", borderDashOffset);
    if (borderJoinStyle != null) {
        JUtils.putNotNull(map, "borderJoinStyle", borderJoinStyle.name().toLowerCase());
    }
    JUtils.putNotNull(map, "capBezierPoints", capBezierPoints);
    if (this.fillMode == null) {
        JUtils.putNotNull(map, "fill", fill);
    } else {
        JUtils.putNotNull(map, "fill", fillMode.name().toLowerCase());
    }
    return map;
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-chartjs,代码行数:24,代码来源:Line.java


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