Java 类com.google.gson.JsonSerializationContext 实例源码

项目:CustomWorldGen    文件:LootEntryItem.java   
protected void serialize(JsonObject json, JsonSerializationContext context)
{
    if (this.functions != null && this.functions.length > 0)
    {
        json.add("functions", context.serialize(this.functions));
    }

    ResourceLocation resourcelocation = (ResourceLocation)Item.REGISTRY.getNameForObject(this.item);

    if (resourcelocation == null)
    {
        throw new IllegalArgumentException("Can\'t serialize unknown item " + this.item);
    }
    else
    {
        json.addProperty("name", resourcelocation.toString());
    }
}
项目:yggdrasil    文件:ProfilePropertyMapSerializer.java   
@Override
public JsonElement serialize(final ProfilePropertyMap src, final Type typeOfSrc, final JsonSerializationContext context) {
  final JsonArray result = new JsonArray();

  for(final ProfileProperty property : src.values()) {
    final JsonObject object = new JsonObject();

    object.addProperty("name", property.name());
    object.addProperty("value", property.value());

    @Nullable final String signature = property.signature();
    if(signature != null) {
      object.addProperty("signature", signature);
    }

    result.add(object);
  }

  return result;
}
项目:Phoenix-for-VK    文件:AttachmentsDboAdapter.java   
@Override
public JsonElement serialize(AttachmentsEntity attachmentsEntity, Type type, JsonSerializationContext context) {
    List<Entity> entities = attachmentsEntity.getEntities();

    JsonArray array = new JsonArray(entities.size());
    for(Entity entity : entities){
        int dbotype = AttachmentsTypes.typeForInstance(entity);

        JsonObject o = new JsonObject();
        o.add(KEY_ENTITY_TYPE, new JsonPrimitive(dbotype));
        o.add(KEY_ENTITY, context.serialize(entity));

        array.add(o);
    }

    return array;
}
项目:BaseClient    文件:ServerStatusResponse.java   
public JsonElement serialize(ServerStatusResponse p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();

    if (p_serialize_1_.getServerDescription() != null)
    {
        jsonobject.add("description", p_serialize_3_.serialize(p_serialize_1_.getServerDescription()));
    }

    if (p_serialize_1_.getPlayerCountData() != null)
    {
        jsonobject.add("players", p_serialize_3_.serialize(p_serialize_1_.getPlayerCountData()));
    }

    if (p_serialize_1_.getProtocolVersionInfo() != null)
    {
        jsonobject.add("version", p_serialize_3_.serialize(p_serialize_1_.getProtocolVersionInfo()));
    }

    if (p_serialize_1_.getFavicon() != null)
    {
        jsonobject.addProperty("favicon", p_serialize_1_.getFavicon());
    }

    return jsonobject;
}
项目:BaseClient    文件:ServerStatusResponse.java   
public JsonElement serialize(ServerStatusResponse.PlayerCountData p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("max", (Number)Integer.valueOf(p_serialize_1_.getMaxPlayers()));
    jsonobject.addProperty("online", (Number)Integer.valueOf(p_serialize_1_.getOnlinePlayerCount()));

    if (p_serialize_1_.getPlayers() != null && p_serialize_1_.getPlayers().length > 0)
    {
        JsonArray jsonarray = new JsonArray();

        for (int i = 0; i < p_serialize_1_.getPlayers().length; ++i)
        {
            JsonObject jsonobject1 = new JsonObject();
            UUID uuid = p_serialize_1_.getPlayers()[i].getId();
            jsonobject1.addProperty("id", uuid == null ? "" : uuid.toString());
            jsonobject1.addProperty("name", p_serialize_1_.getPlayers()[i].getName());
            jsonarray.add(jsonobject1);
        }

        jsonobject.add("sample", jsonarray);
    }

    return jsonobject;
}
项目:Backmemed    文件:EnchantRandomly.java   
public void serialize(JsonObject object, EnchantRandomly functionClazz, JsonSerializationContext serializationContext)
{
    if (!functionClazz.enchantments.isEmpty())
    {
        JsonArray jsonarray = new JsonArray();

        for (Enchantment enchantment : functionClazz.enchantments)
        {
            ResourceLocation resourcelocation = (ResourceLocation)Enchantment.REGISTRY.getNameForObject(enchantment);

            if (resourcelocation == null)
            {
                throw new IllegalArgumentException("Don\'t know how to serialize enchantment " + enchantment);
            }

            jsonarray.add(new JsonPrimitive(resourcelocation.toString()));
        }

        object.add("enchantments", jsonarray);
    }
}
项目:Wechat-Group    文件:WxMpTemplateMessageGsonAdapter.java   
@Override
public JsonElement serialize(WxMpTemplateMessage message, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject messageJson = new JsonObject();
  messageJson.addProperty("touser", message.getToUser());
  messageJson.addProperty("template_id", message.getTemplateId());
  if (message.getUrl() != null) {
    messageJson.addProperty("url", message.getUrl());
  }

  JsonObject data = new JsonObject();
  messageJson.add("data", data);

  for (WxMpTemplateData datum : message.getData()) {
    JsonObject dataJson = new JsonObject();
    dataJson.addProperty("value", datum.getValue());
    if (datum.getColor() != null) {
      dataJson.addProperty("color", datum.getColor());
    }
    data.add(datum.getName(), dataJson);
  }

  return messageJson;
}
项目:DecompiledMinecraft    文件:ServerStatusResponse.java   
public JsonElement serialize(ServerStatusResponse.PlayerCountData p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("max", (Number)Integer.valueOf(p_serialize_1_.getMaxPlayers()));
    jsonobject.addProperty("online", (Number)Integer.valueOf(p_serialize_1_.getOnlinePlayerCount()));

    if (p_serialize_1_.getPlayers() != null && p_serialize_1_.getPlayers().length > 0)
    {
        JsonArray jsonarray = new JsonArray();

        for (int i = 0; i < p_serialize_1_.getPlayers().length; ++i)
        {
            JsonObject jsonobject1 = new JsonObject();
            UUID uuid = p_serialize_1_.getPlayers()[i].getId();
            jsonobject1.addProperty("id", uuid == null ? "" : uuid.toString());
            jsonobject1.addProperty("name", p_serialize_1_.getPlayers()[i].getName());
            jsonarray.add(jsonobject1);
        }

        jsonobject.add("sample", jsonarray);
    }

    return jsonobject;
}
项目:Backmemed    文件:LootPool.java   
public JsonElement serialize(LootPool p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.add("entries", p_serialize_3_.serialize(p_serialize_1_.lootEntries));
    jsonobject.add("rolls", p_serialize_3_.serialize(p_serialize_1_.rolls));

    if (p_serialize_1_.bonusRolls.getMin() != 0.0F && p_serialize_1_.bonusRolls.getMax() != 0.0F)
    {
        jsonobject.add("bonus_rolls", p_serialize_3_.serialize(p_serialize_1_.bonusRolls));
    }

    if (!ArrayUtils.isEmpty((Object[])p_serialize_1_.poolConditions))
    {
        jsonobject.add("conditions", p_serialize_3_.serialize(p_serialize_1_.poolConditions));
    }

    return jsonobject;
}
项目:BaseClient    文件:PackMetadataSectionSerializer.java   
public JsonElement serialize(PackMetadataSection p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("pack_format", (Number)Integer.valueOf(p_serialize_1_.getPackFormat()));
    jsonobject.add("description", p_serialize_3_.serialize(p_serialize_1_.getPackDescription()));
    return jsonobject;
}
项目:mapbox-events-android    文件:NavigationMetadataSerializer.java   
@Override
public JsonElement serialize(NavigationMetadata src, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject metadata = new JsonObject();
  serializeRequired(src, metadata);
  serializeOptional(src, metadata);
  return metadata;
}
项目:CustomWorldGen    文件:AnimationMetadataSectionSerializer.java   
public JsonElement serialize(AnimationMetadataSection p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("frametime", (Number)Integer.valueOf(p_serialize_1_.getFrameTime()));

    if (p_serialize_1_.getFrameWidth() != -1)
    {
        jsonobject.addProperty("width", (Number)Integer.valueOf(p_serialize_1_.getFrameWidth()));
    }

    if (p_serialize_1_.getFrameHeight() != -1)
    {
        jsonobject.addProperty("height", (Number)Integer.valueOf(p_serialize_1_.getFrameHeight()));
    }

    if (p_serialize_1_.getFrameCount() > 0)
    {
        JsonArray jsonarray = new JsonArray();

        for (int i = 0; i < p_serialize_1_.getFrameCount(); ++i)
        {
            if (p_serialize_1_.frameHasTime(i))
            {
                JsonObject jsonobject1 = new JsonObject();
                jsonobject1.addProperty("index", (Number)Integer.valueOf(p_serialize_1_.getFrameIndex(i)));
                jsonobject1.addProperty("time", (Number)Integer.valueOf(p_serialize_1_.getFrameTimeSingle(i)));
                jsonarray.add(jsonobject1);
            }
            else
            {
                jsonarray.add(new JsonPrimitive(Integer.valueOf(p_serialize_1_.getFrameIndex(i))));
            }
        }

        jsonobject.add("frames", jsonarray);
    }

    return jsonobject;
}
项目:mapbox-events-android    文件:RerouteDataSerializer.java   
private void serializeNewData(NavigationRerouteData src, JsonSerializationContext context,
                              JsonObject rerouteData) {
  JsonObject newData = context.serialize(src.getNavigationNewData()).getAsJsonObject();
  for (Map.Entry<String, JsonElement> e : newData.entrySet()) {
    rerouteData.add(e.getKey(), e.getValue());
  }
}
项目:BaseClient    文件:ServerStatusResponse.java   
public JsonElement serialize(ServerStatusResponse.MinecraftProtocolVersionIdentifier p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("name", p_serialize_1_.getName());
    jsonobject.addProperty("protocol", (Number)Integer.valueOf(p_serialize_1_.getProtocol()));
    return jsonobject;
}
项目:buckaroo    文件:RemoteCookBookSerializer.java   
@Override
public JsonElement serialize(final RemoteCookbook cookBook, final Type type, final JsonSerializationContext context) {

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

    final JsonObject jsonObject = new JsonObject();

    jsonObject.add("name", context.serialize(cookBook.name));
    jsonObject.add("url", context.serialize(cookBook.url));

    return jsonObject;
}
项目:mapbox-events-android    文件:LocationDataSerializer.java   
@Override
public JsonElement serialize(NavigationLocationData src, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject locationData = new JsonObject();
  JsonArray locationsBefore = context.serialize(src.getLocationsBefore()).getAsJsonArray();
  JsonArray locationsAfter = context.serialize(src.getLocationsAfter()).getAsJsonArray();
  locationData.add(LOCATIONS_BEFORE, locationsBefore);
  locationData.add(LOCATIONS_AFTER, locationsAfter);
  return locationData;
}
项目:n5    文件:CompressionAdapter.java   
@Override
public JsonElement serialize(Compression compression, Type typeOfSrc, JsonSerializationContext context) {

    final String type = compression.getType();
    final Class<? extends Compression> clazz = compression.getClass();

    JsonObject json = new JsonObject();
    json.addProperty("type", type);

    final HashMap<String, Class<?>> parameterTypes = compressionParameters.get(type);
    try {
        for (final Entry<String, Class<?>> parameterType : parameterTypes.entrySet()) {
            final String name = parameterType.getKey();
            Field field = clazz.getDeclaredField(name);
            final boolean isAccessible = field.isAccessible();
            field.setAccessible(true);
            final Object value = field.get(compression);
            field.setAccessible(isAccessible);
            json.add(parameterType.getKey(), context.serialize(value));
        }
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace(System.err);
        return null;
    }

    return json;
}
项目:jSpace    文件:TemplateSerializer.java   
@Override
public JsonElement serialize(Template src, Type typeOfSrc, JsonSerializationContext context) {
    JsonArray toReturn = new JsonArray();
    jSonUtils utils = jSonUtils.getInstance();
    for (TemplateField f : src) {
        toReturn.add(utils.jsonFromTeplate(f, context));
    }
    return toReturn;
}
项目:hypertrack-live-android    文件:LocationSerializer.java   
public JsonElement serialize(Location t, Type type,
                             JsonSerializationContext jsc) {
    JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty("mProvider", t.getProvider());
    jsonObject.addProperty("mAccuracy", t.getAccuracy());
    jsonObject.addProperty("mLatitude", t.getLatitude());
    jsonObject.addProperty("mLongitude", t.getLongitude());
    jsonObject.addProperty("mTime", t.getTime());
    jsonObject.addProperty("mSpeed", t.getSpeed());
    jsonObject.addProperty("mBearing", t.getBearing());
    return jsonObject;
}
项目:Backmemed    文件:PlayerProfileCache.java   
public JsonElement serialize(PlayerProfileCache.ProfileEntry p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("name", p_serialize_1_.getGameProfile().getName());
    UUID uuid = p_serialize_1_.getGameProfile().getId();
    jsonobject.addProperty("uuid", uuid == null ? "" : uuid.toString());
    jsonobject.addProperty("expiresOn", PlayerProfileCache.DATE_FORMAT.format(p_serialize_1_.getExpirationDate()));
    return jsonobject;
}
项目:nifi-swagger-client    文件:JSON.java   
/**
 * Serialize
 *
 * @param src Date
 * @param typeOfSrc Type
 * @param context Json Serialization Context
 * @return Json Element
 */
@Override
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
    if (src == null) {
        return JsonNull.INSTANCE;
    } else {
        return new JsonPrimitive(apiClient.formatDatetime(src));
    }
}
项目:CustomWorldGen    文件:ServerStatusResponse.java   
public JsonElement serialize(ServerStatusResponse p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();

    if (p_serialize_1_.getServerDescription() != null)
    {
        jsonobject.add("description", p_serialize_3_.serialize(p_serialize_1_.getServerDescription()));
    }

    if (p_serialize_1_.getPlayers() != null)
    {
        jsonobject.add("players", p_serialize_3_.serialize(p_serialize_1_.getPlayers()));
    }

    if (p_serialize_1_.getVersion() != null)
    {
        jsonobject.add("version", p_serialize_3_.serialize(p_serialize_1_.getVersion()));
    }

    if (p_serialize_1_.getFavicon() != null)
    {
        jsonobject.addProperty("favicon", p_serialize_1_.getFavicon());
    }

    net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.enhanceStatusQuery(jsonobject);
    return jsonobject;
}
项目:Backmemed    文件:AnimationMetadataSectionSerializer.java   
public JsonElement serialize(AnimationMetadataSection p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("frametime", (Number)Integer.valueOf(p_serialize_1_.getFrameTime()));

    if (p_serialize_1_.getFrameWidth() != -1)
    {
        jsonobject.addProperty("width", (Number)Integer.valueOf(p_serialize_1_.getFrameWidth()));
    }

    if (p_serialize_1_.getFrameHeight() != -1)
    {
        jsonobject.addProperty("height", (Number)Integer.valueOf(p_serialize_1_.getFrameHeight()));
    }

    if (p_serialize_1_.getFrameCount() > 0)
    {
        JsonArray jsonarray = new JsonArray();

        for (int i = 0; i < p_serialize_1_.getFrameCount(); ++i)
        {
            if (p_serialize_1_.frameHasTime(i))
            {
                JsonObject jsonobject1 = new JsonObject();
                jsonobject1.addProperty("index", (Number)Integer.valueOf(p_serialize_1_.getFrameIndex(i)));
                jsonobject1.addProperty("time", (Number)Integer.valueOf(p_serialize_1_.getFrameTimeSingle(i)));
                jsonarray.add(jsonobject1);
            }
            else
            {
                jsonarray.add(new JsonPrimitive(Integer.valueOf(p_serialize_1_.getFrameIndex(i))));
            }
        }

        jsonobject.add("frames", jsonarray);
    }

    return jsonobject;
}
项目:skywalking-mock-collector    文件:ValidateDataSerializer.java   
@Override
public JsonElement serialize(ValidateData src, Type typeOfSrc, JsonSerializationContext context) {
    Gson gson = new GsonBuilder().registerTypeAdapter(RegistryItem.class, new RegistryItemSerializer())
        .registerTypeAdapter(SegmentItems.class, new SegmentItemsSerializer()).create();

    JsonObject jsonObject = new JsonObject();
    jsonObject.add("registryItems", gson.toJsonTree(src.getRegistryItem()));
    jsonObject.add("segmentItems", gson.toJsonTree(src.getSegmentItem()));
    return jsonObject;
}
项目:PI-Web-API-Client-Java-Android    文件:JSON.java   
/**
 * Serialize
 *
 * @param src Date
 * @param typeOfSrc Type
 * @param context Json Serialization Context
 * @return Json Element
 */
@Override
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
    if (src == null) {
        return JsonNull.INSTANCE;
    } else {
        return new JsonPrimitive(apiClient.formatDatetime(src));
    }
}
项目:mapbox-events-android    文件:FeedbackEventSerializer.java   
private void serializeFeedbackEventData(NavigationFeedbackEvent src, JsonSerializationContext context,
                                        JsonObject feedbackEvent) {
  JsonObject feedbackEventData = context.serialize(src.getFeedbackEventData()).getAsJsonObject();
  for (Map.Entry<String, JsonElement> e : feedbackEventData.entrySet()) {
    feedbackEvent.add(e.getKey(), e.getValue());
  }
}
项目:mazes_and_minotaurs    文件:CharacterSerializer.java   
@Override
public JsonElement serialize(PlayerCharacter src, Type typeOfSrc, JsonSerializationContext context) {
    BaseClass characterClass = src.getCharClass();
    characterClass.setCharacter(null);

    Type equipListType = new TypeToken<ArrayList<Equipment>>() {
    }.getType();
    Type moneyMapType = new TypeToken<HashMap<Money, Integer>>() {
    }.getType();

    JsonObject rootObject = new JsonObject();
    rootObject.add("mScores", context.serialize(src.getScores()));
    rootObject.add("mCharClass", context.serialize(src.getCharClass(), BaseClass.class));
    rootObject.add("mGender", context.serialize(src.getGender()));
    rootObject.add("mMoney", context.serialize(src.getMoney(), moneyMapType));
    rootObject.add("mAge", context.serialize(src.getAge()));
    rootObject.add("mName", context.serialize(src.getName()));
    System.out.println(getGson().toJsonTree(src.getInventory(), equipListType));
    rootObject.add("mInventory", getGson().toJsonTree(src.getInventory(), equipListType));
    rootObject.add("mCurrentWeapon", context.serialize(src.getCurrentWeapon()));
    rootObject.add("mHelmet", context.serialize(src.getHelmet()));
    rootObject.add("mBreastplate", context.serialize(src.getBreastplate()));
    rootObject.add("mShield", context.serialize(src.getShield()));
    rootObject.add("mPatron", context.serialize(src.getPatron()));

    JsonElement classJson = context.serialize(characterClass);
    classJson.getAsJsonObject().remove("mResId");
    rootObject.add("mCharClass", classJson);

    characterClass.setCharacter(src);
    return rootObject;
}
项目:Backmemed    文件:EntityHasScore.java   
public void serialize(JsonObject json, EntityHasScore value, JsonSerializationContext context)
{
    JsonObject jsonobject = new JsonObject();

    for (Entry<String, RandomValueRange> entry : value.scores.entrySet())
    {
        jsonobject.add((String)entry.getKey(), context.serialize(entry.getValue()));
    }

    json.add("scores", jsonobject);
    json.add("entity", context.serialize(value.target));
}
项目:IPE-LWM2M    文件:SecuritySerializer.java   
@Override
public JsonElement serialize(SecurityInfo src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject element = new JsonObject();

    element.addProperty("endpoint", src.getEndpoint());

    if (src.getIdentity() != null) {
        JsonObject psk = new JsonObject();
        psk.addProperty("identity", src.getIdentity());
        psk.addProperty("key", Hex.encodeHexString(src.getPreSharedKey()));
        element.add("psk", psk);
    }

    if (src.getRawPublicKey() != null) {
        JsonObject rpk = new JsonObject();
        PublicKey rawPublicKey = src.getRawPublicKey();
        if (rawPublicKey instanceof ECPublicKey) {
            ECPublicKey ecPublicKey = (ECPublicKey) rawPublicKey;
            // Get x coordinate
            byte[] x = ecPublicKey.getW().getAffineX().toByteArray();
            if (x[0] == 0)
                x = Arrays.copyOfRange(x, 1, x.length);
            rpk.addProperty("x", Hex.encodeHexString(x));

            // Get Y coordinate
            byte[] y = ecPublicKey.getW().getAffineY().toByteArray();
            if (y[0] == 0)
                y = Arrays.copyOfRange(y, 1, y.length);
            rpk.addProperty("y", Hex.encodeHexString(y));

            // Get Curves params
            rpk.addProperty("params", ecPublicKey.getParams().toString());
        } else {
            throw new JsonParseException("Unsupported Public Key Format (only ECPublicKey supported).");
        }
        element.add("rpk", rpk);
    }

    return element;
}
项目:mapbox-events-android    文件:RerouteDataSerializer.java   
@Override
public JsonElement serialize(NavigationRerouteData src, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject rerouteData = new JsonObject();
  rerouteData.addProperty(SECOND_SINCE_LAST_REROUTE, src.getSecondsSinceLastReroute());
  serializeNewData(src, context, rerouteData);
  return rerouteData;
}
项目:mapbox-events-android    文件:FeedbackDataSerializer.java   
@Override
public JsonElement serialize(FeedbackData src, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject feedbackData = new JsonObject();
  feedbackData.addProperty(FEEDBACK_ID, src.getFeedbackId());
  feedbackData.addProperty(SCREENSHOT, src.getScreenshot());
  return feedbackData;
}
项目:BaseClient    文件:IChatComponent.java   
private void serializeChatStyle(ChatStyle style, JsonObject object, JsonSerializationContext ctx)
{
    JsonElement jsonelement = ctx.serialize(style);

    if (jsonelement.isJsonObject())
    {
        JsonObject jsonobject = (JsonObject)jsonelement;

        for (Entry<String, JsonElement> entry : jsonobject.entrySet())
        {
            object.add((String)entry.getKey(), (JsonElement)entry.getValue());
        }
    }
}
项目:BaseClient    文件:PackMetadataSectionSerializer.java   
public JsonElement serialize(PackMetadataSection p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("pack_format", (Number)Integer.valueOf(p_serialize_1_.getPackFormat()));
    jsonobject.add("description", p_serialize_3_.serialize(p_serialize_1_.getPackDescription()));
    return jsonobject;
}
项目:DecompiledMinecraft    文件:ServerStatusResponse.java   
public JsonElement serialize(ServerStatusResponse.MinecraftProtocolVersionIdentifier p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("name", p_serialize_1_.getName());
    jsonobject.addProperty("protocol", (Number)Integer.valueOf(p_serialize_1_.getProtocol()));
    return jsonobject;
}
项目:mapbox-events-android    文件:VoiceDataSerializer.java   
@Override
public JsonElement serialize(NavigationVoiceData src, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject voiceData = new JsonObject();
  voiceData.addProperty(VOICE_INSTRUCTION, src.getVoiceInstruction());
  voiceData.addProperty(VOICE_INSTRUCTION_TIMESTAMP, src.getVoiceInstructionTimestamp());
  return voiceData;
}
项目:DecompiledMinecraft    文件:PlayerProfileCache.java   
public JsonElement serialize(PlayerProfileCache.ProfileEntry p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("name", p_serialize_1_.getGameProfile().getName());
    UUID uuid = p_serialize_1_.getGameProfile().getId();
    jsonobject.addProperty("uuid", uuid == null ? "" : uuid.toString());
    jsonobject.addProperty("expiresOn", PlayerProfileCache.dateFormat.format(p_serialize_1_.getExpirationDate()));
    return jsonobject;
}
项目:mapbox-events-android    文件:ArriveEventSerializer.java   
private void serializeMetadata(NavigationArriveEvent src, JsonSerializationContext context,
                               JsonObject arriveEvent) {
  JsonObject metadata = context.serialize(src.getMetadata()).getAsJsonObject();
  for (Map.Entry<String, JsonElement> e : metadata.entrySet()) {
    arriveEvent.add(e.getKey(), e.getValue());
  }
}
项目:CustomWorldGen    文件:ITextComponent.java   
private void serializeChatStyle(Style style, JsonObject object, JsonSerializationContext ctx)
{
    JsonElement jsonelement = ctx.serialize(style);

    if (jsonelement.isJsonObject())
    {
        JsonObject jsonobject = (JsonObject)jsonelement;

        for (Entry<String, JsonElement> entry : jsonobject.entrySet())
        {
            object.add((String)entry.getKey(), (JsonElement)entry.getValue());
        }
    }
}
项目:opentest    文件:ScriptObjectMirrorSerializer.java   
@Override
public JsonElement serialize(ScriptObjectMirror src, java.lang.reflect.Type typeOfSrc, JsonSerializationContext context) {
    Gson gson = new Gson();

    if (src.isArray()) {
        return gson.toJsonTree(src.values());
    } else {
        return gson.toJsonTree(src);
    }
}
项目:DecompiledMinecraft    文件:PlayerProfileCache.java   
public JsonElement serialize(PlayerProfileCache.ProfileEntry p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("name", p_serialize_1_.getGameProfile().getName());
    UUID uuid = p_serialize_1_.getGameProfile().getId();
    jsonobject.addProperty("uuid", uuid == null ? "" : uuid.toString());
    jsonobject.addProperty("expiresOn", PlayerProfileCache.dateFormat.format(p_serialize_1_.getExpirationDate()));
    return jsonobject;
}