本文整理汇总了Java中elemental.json.JsonObject.put方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.put方法的具体用法?Java JsonObject.put怎么用?Java JsonObject.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elemental.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.put方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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);
}
示例3: 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);
}
}
示例4: 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());
}
示例5: putNotNullIntListOrSingle
import elemental.json.JsonObject; //导入方法依赖的package包/类
public static void putNotNullIntListOrSingle(JsonObject obj, String key, List<Integer> listOfNumbers) {
if (listOfNumbers != null) {
if (listOfNumbers.size() == 1) {
putNotNull(obj, key, listOfNumbers.get(0));
} else {
JsonArray arr = Json.createArray();
for (Integer n : listOfNumbers) {
arr.set(arr.length(), n.doubleValue());
}
obj.put(key, arr);
}
}
}
示例6: socketSend
import elemental.json.JsonObject; //导入方法依赖的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());
}
示例7: putNotNullNumbers
import elemental.json.JsonObject; //导入方法依赖的package包/类
public static void putNotNullNumbers(JsonObject obj, String key, List<Double> listOfNumbers) {
if (listOfNumbers != null) {
JsonArray arr = Json.createArray();
for (Double n : listOfNumbers) {
if (n == null) {
arr.set(arr.length(), new JreJsonNull());
} else {
arr.set(arr.length(), n);
}
}
obj.put(key, arr);
}
}
示例8: 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);
}
}
示例9: putNotNullStringListOrSingle
import elemental.json.JsonObject; //导入方法依赖的package包/类
public static void putNotNullStringListOrSingle(JsonObject obj, String key, List<String> list) {
if (list != null) {
if (list.size() == 1) {
putNotNull(obj, key, list.get(0));
} else {
JsonArray arr = Json.createArray();
for (String entry : list) {
arr.set(arr.length(), entry);
}
obj.put(key, arr);
}
}
}
示例10: toJson
import elemental.json.JsonObject; //导入方法依赖的package包/类
protected JsonArray toJson(List<MenuItem> menuItems) {
JsonArray array = Json.createArray();
int i = 0;
for (MenuItem menuItem : menuItems) {
if (menuItem.isVisible()) {
JsonObject item = Json.createObject();
item.put(MENU_ITEM_ID, Json.create(menuItemIdMapper.key(menuItem)));
if (menuItem.getCaption() != null) {
item.put(MENU_ITEM_CAPTION, Json.create(menuItem.getCaption()));
}
if (menuItem.getDescription() != null) {
item.put(MENU_ITEM_DESCRIPTION, Json.create(menuItem.getDescription()));
}
if (menuItem.getStyleName() != null) {
item.put(MENU_ITEM_STYLE_NAME, Json.create(menuItem.getStyleName()));
}
item.put(MENU_ITEM_EXPANDED, Json.create(menuItem.isExpanded()));
item.put(MENU_ITEM_CAPTION_AS_HTML, Json.create(menuItem.isCaptionAsHtml()));
if (menuItem.getBadgeText() != null) {
item.put(MENU_ITEM_BADGE_TEXT, Json.create(menuItem.getBadgeText()));
}
if (menuItem.getCubaId() != null) {
item.put(MENU_ITEM_CUBA_ID, Json.create(menuItem.getCubaId()));
}
if (menuItem.getIcon() != null) {
String resourceKey = menuIconsKeyMapper.key(menuItem.getIcon());
menuIconResourceKeys.add(resourceKey);
setResource(resourceKey, menuItem.getIcon());
item.put(MENU_ITEM_ICON, Json.create(resourceKey));
}
if (!menuItem.getChildren().isEmpty()) {
JsonArray childrenJsonArray = toJson(menuItem.getChildren());
item.put(MENU_ITEM_CHILDREN, childrenJsonArray);
}
array.set(i, item);
i++;
}
}
return array;
}
示例11: putNotNullIntList
import elemental.json.JsonObject; //导入方法依赖的package包/类
public static void putNotNullIntList(JsonObject obj, String key, List<Integer> listOfNumbers) {
if (listOfNumbers != null) {
JsonArray arr = Json.createArray();
for (Integer n : listOfNumbers) {
arr.set(arr.length(), n.doubleValue());
}
obj.put(key, arr);
}
}