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


Java JsonObject.addProperty方法代码示例

本文整理汇总了Java中com.google.gson.JsonObject.addProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.addProperty方法的具体用法?Java JsonObject.addProperty怎么用?Java JsonObject.addProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gson.JsonObject的用法示例。


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

示例1: overrideDefaultSettings

import com.google.gson.JsonObject; //导入方法依赖的package包/类
/**
 * Overrides default setting with the settings fetched fron the community.
 *
 * @param clientSettings    Local settings to be used.
 * @param serverSettingJson Settings received from community.
 */
private static void overrideDefaultSettings(JsonObject clientSettings, JsonObject serverSettingJson) {
    if (serverSettingJson != null && !serverSettingJson.isJsonNull()) {
        if (serverSettingJson.has("response_limit")) {
            int limit = serverSettingJson.get("response_limit").getAsInt();
            clientSettings.addProperty("limit", limit);
        }

        if (serverSettingJson.has("discussion_style")) {
            JsonArray discussionStyleArr = serverSettingJson.get("discussion_style").getAsJsonArray();
            StringBuilder conversationStyleSB = new StringBuilder();
            boolean isFirst = true;
            conversationStyleSB.append("(");
            for (JsonElement styleElem : discussionStyleArr) {
                if (isFirst) {
                    isFirst = false;
                } else {
                    conversationStyleSB.append(", ");
                }
                conversationStyleSB.append("'").append(styleElem.getAsString()).append("'");
            }
            conversationStyleSB.append(")");
            if (clientSettings.has("whereClauses")) {
                JsonArray whereArr = clientSettings.get("whereClauses").getAsJsonArray();
                for (JsonElement whereElem : whereArr) {
                    JsonObject whereObj = whereElem.getAsJsonObject();
                    if (whereObj.has("key")) {
                        String key = whereObj.get("key").getAsString();
                        if (key.equals("conversation.style")) {
                            whereObj.addProperty("value", conversationStyleSB.toString());
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:lithiumtech,项目名称:li-android-sdk-core,代码行数:43,代码来源:LiQueryBuilder.java

示例2: getRequestJsonObject

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private JsonObject getRequestJsonObject(Logger logger, boolean logFailedRequests) {
    JsonObject chart = new JsonObject();
    chart.addProperty("chartId", chartId);
    try {
        JsonObject data = getChartData();
        if (data == null) {
            // If the data is null we don't send the chart.
            return null;
        }
        chart.add("data", data);
    } catch (Throwable t) {
        if (logFailedRequests) {
            logger.warn("Failed to get data for custom chart with id {}", chartId, t);
        }
        return null;
    }
    return chart;
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:19,代码来源:Metrics.java

示例3: testUpdateGroupChat

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Test
public void testUpdateGroupChat() {
    JsonObject json = new JsonObject();
    json.addProperty("userId", 1);
    json.addProperty("datetime", new Date().toString());
    json.addProperty("content", "haha");
    ArrayList<String> chats = new ArrayList<String>();
    chats.add(json.toString());
    GroupChat groupChat = new GroupChat(1, chats);

    groupChatDao.addGroupChat(groupChat);
    groupChat = groupChatDao.getAllGroupChats().get(0);
    ArrayList<String> newList = new ArrayList<String>();
    newList.add("hhh");
    groupChat.setContents(newList);
    groupChatDao.updateGroupChat(groupChat);

    Assert.assertEquals(groupChatDao.getAllGroupChats().get(0).getContents(), newList);

    groupChatDao.deleteGroupChat(groupChat);
}
 
开发者ID:qinjr,项目名称:TeamNote,代码行数:22,代码来源:GroupChatDaoImplTest.java

示例4: writeObservationsToJSON

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Override
public void writeObservationsToJSON(JsonObject json, MissionInit missionInit)
{
	// Return a string that is unique for every cell on the x/z plane (ignores y)
	EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
	// getPosition() rounds to int.
	int x = player.getPosition().getX();
	int z = player.getPosition().getZ();
	json.addProperty("cell", "(" + x + "," + z + ")");
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:11,代码来源:ObservationFromDiscreteCellImplementation.java

示例5: addAggStdInfo

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private static void addAggStdInfo(JsonObject jo, List<JsonObject> samples) {
    // beginMsec, endMsec, nSamples
    long msec = samples.get(0).get(KEY_TS).getAsLong();
    long msec2 = samples.get(samples.size()-1).get(KEY_TS).getAsLong();
    int nSamples = samples.size();
    
    jo.addProperty(KEY_TS, msec2);
    jo.addProperty(KEY_AGG_BEGIN_TS, msec);
    jo.addProperty(KEY_AGG_COUNT, nSamples);
}
 
开发者ID:osswangxining,项目名称:iot-edge-greengrass,代码行数:11,代码来源:JsonTuples.java

示例6: banNote

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@RequestMapping("/banNote")
@ResponseBody
public String banNote(@RequestParam("verifyId") int verifyId) {
    adminService.banNote(verifyId);
    JsonObject obj = new JsonObject();
    obj.addProperty("result","success");
    return new Gson().toJson(obj);
}
 
开发者ID:qinjr,项目名称:TeamNote,代码行数:9,代码来源:AdminController.java

示例7: onSerialization

import com.google.gson.JsonObject; //导入方法依赖的package包/类
protected void onSerialization(JsonObject data)
{
    if (this.getValue() != null)
    {
        data.addProperty("uuid", ((GameProfile)this.getValue()).getId() == null ? "" : ((GameProfile)this.getValue()).getId().toString());
        data.addProperty("name", ((GameProfile)this.getValue()).getName());
        super.onSerialization(data);
        data.addProperty("level", (Number)Integer.valueOf(this.permissionLevel));
        data.addProperty("bypassesPlayerLimit", Boolean.valueOf(this.bypassesPlayerLimit));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:12,代码来源:UserListOpsEntry.java

示例8: tagCreate

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Override
public WxUserTag tagCreate(String name) throws WxErrorException {
  String url = API_URL_PREFIX + "/create";
  JsonObject json = new JsonObject();
  JsonObject tagJson = new JsonObject();
  tagJson.addProperty("name", name);
  json.add("tag", tagJson);

  String responseContent = this.wxMpService.post(url, json.toString());
  return WxUserTag.fromJson(responseContent);
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:12,代码来源:WxMpUserTagServiceImpl.java

示例9: onSerialization

import com.google.gson.JsonObject; //导入方法依赖的package包/类
protected void onSerialization(JsonObject data)
{
    data.addProperty("created", dateFormat.format(this.banStartDate));
    data.addProperty("source", this.bannedBy);
    data.addProperty("expires", this.banEndDate == null ? "forever" : dateFormat.format(this.banEndDate));
    data.addProperty("reason", this.reason);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:8,代码来源:BanEntry.java

示例10: onSerialization

import com.google.gson.JsonObject; //导入方法依赖的package包/类
protected void onSerialization(JsonObject data)
{
    if (this.getValue() != null)
    {
        data.addProperty("uuid", ((GameProfile)this.getValue()).getId() == null ? "" : ((GameProfile)this.getValue()).getId().toString());
        data.addProperty("name", ((GameProfile)this.getValue()).getName());
        super.onSerialization(data);
        data.addProperty("level", (Number)Integer.valueOf(this.field_152645_a));
        data.addProperty("bypassesPlayerLimit", Boolean.valueOf(this.field_183025_b));
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:12,代码来源:UserListOpsEntry.java

示例11: serialize

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Override
public JsonElement serialize(WidgetPane src, JsonSerializationContext context) {
  JsonObject object = new JsonObject();
  object.addProperty("gridSize", src.getTileSize());
  object.addProperty("hgap", src.getHgap());
  object.addProperty("vgap", src.getVgap());
  JsonObject tiles = new JsonObject();

  for (Tile<?> tile : src.getTiles()) {
    String x = GridPane.getColumnIndex(tile).toString();
    String y = GridPane.getRowIndex(tile).toString();
    String coordinate = String.join(",", x, y);

    JsonObject tileObject = new JsonObject();
    tileObject.add("size", context.serialize(tile.getSize(), TileSize.class));
    tileObject.add("content", context.serialize(tile.getContent(), tile.getContent().getClass()));

    tiles.add(coordinate, tileObject);
  }
  object.add("tiles", tiles);

  return object;
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:24,代码来源:WidgetPaneSaver.java

示例12: serialize

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Override
public JsonElement serialize(
        final RecipeVersion recipeVersion, final Type type, final JsonSerializationContext context) {

    Preconditions.checkNotNull(recipeVersion);
    Preconditions.checkNotNull(type);
    Preconditions.checkNotNull(context);

    final JsonObject jsonObject = new JsonObject();

    final JsonElement sourceElement = Either.join(
        recipeVersion.source,
        context::serialize,
        context::serialize);

    jsonObject.add("source", sourceElement);

    if (recipeVersion.target.isPresent()) {
        jsonObject.addProperty("target", recipeVersion.target.get());
    }

    if (recipeVersion.dependencies.map(DependencyGroup::any).orElse(false)) {
        jsonObject.add("dependencies", context.serialize(recipeVersion.dependencies.get()));
    }

    if (recipeVersion.buckResource.isPresent()) {
        jsonObject.add("buck", context.serialize(recipeVersion.buckResource.get(), RemoteFile.class));
    }

    return jsonObject;
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:32,代码来源:RecipeVersionSerializer.java

示例13: sendMessage

import com.google.gson.JsonObject; //导入方法依赖的package包/类
/**
 * @param content Content of the message to be sent
 * @return The newly sent message.
 */
public Message sendMessage(String content)
{
	JsonObject json = new JsonObject();
	json.addProperty("content", content);
	return (Message) DiscordAPI.request("POST", "/channels/" + id + "/messages", json.toString(), new Message());
}
 
开发者ID:timmyrs,项目名称:SuprDiscordBot,代码行数:11,代码来源:Channel.java

示例14: shortJson

import com.google.gson.JsonObject; //导入方法依赖的package包/类
/**
 * @see GenericDefinition#shortJson()
 */
@Override
public JsonElement shortJson() {
    JsonObject json = new JsonObject();
    json.addProperty("band", band.getName());
    json.addProperty("region", region.getId());
    return json;
}
 
开发者ID:spectrumauctions,项目名称:sats-core,代码行数:11,代码来源:MRVMGenericDefinition.java

示例15: updateFromSync

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Test
public void updateFromSync() {
	JsonObject data = new JsonObject();

	data.addProperty("type", "m.presence");

	JsonObject content = new JsonObject();
	content.addProperty("presence", "offline");
	data.add("content", content);

	user.update(data);

	Assert.assertEquals("User object did not parse presence sync data", user.getPresence(), User.Presence.OFFLINE);
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:15,代码来源:UserTest.java


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