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


Java JsonSerializationContext.serialize方法代码示例

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


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

示例1: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(Holder src, Type type, JsonSerializationContext context) {
  JsonObject root = new JsonObject();
  JsonElement value = context.serialize(src.value());

  root.addProperty("id", src.id());

  if (value.isJsonObject()) {
    value.getAsJsonObject().addProperty(Holder.TYPE_PROPERTY, src.value().getClass().getName());
  }

  root.add(VALUE_PROPERTY, value);
  return root;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:HolderJsonSerializer.java

示例2: serializeChatStyle

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
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());
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:ITextComponent.java

示例3: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(final AbstractDXRAMServiceConfig p_abstractDXRAMService, final Type p_type,
        final JsonSerializationContext p_jsonSerializationContext) {

    Class<?> clazz;
    try {
        clazz = Class.forName(p_abstractDXRAMService.getClass().getName());
    } catch (final ClassNotFoundException ignore) {
        return null;
    }

    return p_jsonSerializationContext.serialize(p_abstractDXRAMService, clazz);
}
 
开发者ID:hhu-bsinfo,项目名称:dxram,代码行数:14,代码来源:DXRAMGsonContext.java

示例4: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@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);
    rootObject.add("mCharClass", classJson);

    characterClass.setCharacter(src);
    return rootObject;
}
 
开发者ID:CIS-Extra,项目名称:mazes_and_minotaurs,代码行数:32,代码来源:CharacterSerializer.java

示例5: serializeChatStyle

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
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());
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:15,代码来源:IChatComponent.java

示例6: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(GenericZoneSetting src, Type srcType, JsonSerializationContext context) {
    if (src instanceof HeatingZoneSetting) {
        return context.serialize(src, HeatingZoneSetting.class);
    } else if (src instanceof CoolingZoneSetting) {
        return context.serialize(src, CoolingZoneSetting.class);
    } else if (src instanceof HotWaterZoneSetting) {
        return context.serialize(src, HotWaterZoneSetting.class);
    }

    return new JsonObject();
}
 
开发者ID:dfrommi,项目名称:openhab-tado,代码行数:13,代码来源:ZoneSettingConverter.java

示例7: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(OverlayTerminationCondition src, Type srcType, JsonSerializationContext context) {
    if (src instanceof ManualTerminationCondition) {
        return context.serialize(src, ManualTerminationCondition.class);
    } else if (src instanceof TadoModeTerminationCondition) {
        return context.serialize(src, TadoModeTerminationCondition.class);
    } else if (src instanceof TimerTerminationCondition) {
        return context.serialize(src, TimerTerminationCondition.class);
    }

    return new JsonObject();
}
 
开发者ID:dfrommi,项目名称:openhab-tado,代码行数:13,代码来源:TerminationConditionConverter.java

示例8: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(GenericZoneCapabilities src, Type srcType, JsonSerializationContext context) {
    if (src instanceof HeatingCapabilities) {
        return context.serialize(src, HeatingCapabilities.class);
    } else if (src instanceof AirConditioningCapabilities) {
        return context.serialize(src, AirConditioningCapabilities.class);
    } else if (src instanceof HotWaterCapabilities) {
        return context.serialize(src, HotWaterCapabilities.class);
    }

    return new JsonObject();
}
 
开发者ID:dfrommi,项目名称:openhab-tado,代码行数:13,代码来源:ZoneCapabilitiesConverter.java

示例9: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@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;
}
 
开发者ID:CIS-Extra,项目名称:mazes_and_minotaurs,代码行数:33,代码来源:CharacterSerializer.java

示例10: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
@Nonnull
public JsonElement serialize(@Nonnull Phase src, @Nonnull Type typeOfSrc, @Nonnull JsonSerializationContext context) {
    return context.serialize(src, src.getClass());
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:6,代码来源:GameTypeAdapter.java

示例11: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(final AbstractApplication p_abstractApplication, final Type p_type,
        final JsonSerializationContext p_jsonSerializationContext) {

    return p_jsonSerializationContext.serialize(p_abstractApplication, m_appClass);
}
 
开发者ID:hhu-bsinfo,项目名称:dxram,代码行数:7,代码来源:ApplicationGsonContext.java

示例12: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(CredentialDetail src, Type typeOfSrc, JsonSerializationContext context) {
    return context.serialize(src, src.getClass());
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:5,代码来源:CredentialDetail.java

示例13: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(AbstractButton button, Type type, JsonSerializationContext context) {
	return context.serialize(button);
}
 
开发者ID:jweixin,项目名称:jwx,代码行数:5,代码来源:AbstractButtonAdapter.java

示例14: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(Button button, Type type, JsonSerializationContext context) {
	return context.serialize(button);
}
 
开发者ID:jweixin,项目名称:jwx,代码行数:5,代码来源:ButtonAdapter.java

示例15: serialize

import com.google.gson.JsonSerializationContext; //导入方法依赖的package包/类
@Override
public JsonElement serialize(AbstractMenu menu, Type type, JsonSerializationContext context) {
	return context.serialize(menu);
}
 
开发者ID:jweixin,项目名称:jwx,代码行数:5,代码来源:AbstractMenuAdapter.java


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