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


Java JsonDeserializationContext.deserialize方法代码示例

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


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

示例1: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public Weapon deserialize(final JsonElement json,
                          final java.lang.reflect.Type typeOfT,
                          final JsonDeserializationContext context) throws JsonParseException {
    if (json == null) {
        return null;
    }
    final JsonObject jsonObject = json.getAsJsonObject();
    if (jsonObject == null) {
        return null;
    }
    String type = jsonObject.get(TYPE).getAsString();
    if (Melee.name().equalsIgnoreCase(type)) {
        return context.deserialize(jsonObject, MeleeWeapon.class);
    } else if (Grenade.name().equalsIgnoreCase(type)) {
        return context.deserialize(jsonObject, GrenadeWeapon.class);
    } else {
        return context.deserialize(jsonObject, ProjectileWeapon.class);
    }
}
 
开发者ID:ZafraniTechLLC,项目名称:Companion-For-PUBG-Android,代码行数:21,代码来源:Weapon.java

示例2: parse

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
void parse(JsonObject root, T dto, JsonDeserializationContext context) {
    super.parse(root, dto, context);
    dto.copies = context.deserialize(root.get("feedback"), Copies.class);

    Class<? extends Copyable> copyClass;

    switch (dto.type) {
        case "copy_post":
            copyClass = VKApiPost.class;
            break;
        case "copy_photo":
            copyClass = VKApiPhoto.class;
            break;
        case "copy_video":
            copyClass = VKApiVideo.class;
            break;
        default:
            throw new UnsupportedOperationException("Unsupported feedback type: " + dto.type);
    }

    dto.what = context.deserialize(root.get("parent"), copyClass);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:24,代码来源:FeedbackDtoAdapter.java

示例3: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public AbstractApplication deserialize(final JsonElement p_jsonElement, final Type p_type,
        final JsonDeserializationContext p_jsonDeserializationContext) {

    JsonObject jsonObj = p_jsonElement.getAsJsonObject();
    String className = jsonObj.get("m_class").getAsString();
    boolean enabled = jsonObj.get("m_enabled").getAsBoolean();

    // don't create instance if disabled
    if (!enabled) {
        return null;
    }

    if (!m_appClass.getSuperclass().equals(AbstractApplication.class)) {
        // check if there is an "interface"/abstract class between DXRAMComponent and the instance to
        // create
        if (!m_appClass.getSuperclass().getSuperclass().equals(AbstractApplication.class)) {
            LOGGER.fatal("Could class '%s' is not a subclass of AbstractApplication, check your config file", className);
            return null;
        }
    }

    return p_jsonDeserializationContext.deserialize(p_jsonElement, m_appClass);
}
 
开发者ID:hhu-bsinfo,项目名称:dxram,代码行数:25,代码来源:ApplicationGsonContext.java

示例4: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public EntityWrapper deserialize(JsonElement jsonElement, Type typef, JsonDeserializationContext context) throws JsonParseException {
    if (jsonElement == null || jsonElement instanceof JsonNull) {
        return null;
    }

    JsonObject root = jsonElement.getAsJsonObject();

    boolean isNull = root.get(KEY_IS_NULL).getAsBoolean();

    Entity entity = null;
    if (!isNull) {
        int dbotype = root.get(KEY_TYPE).getAsInt();
        entity = context.deserialize(root.get(KEY_ENTITY), AttachmentsTypes.classForType(dbotype));
    }

    return new EntityWrapper(entity);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:19,代码来源:DboWrapperAdapter.java

示例5: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public JsonJsonModel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException
{
    JsonObject jsonObject = json.getAsJsonObject();
    JsonJsonModel model = JsonFactory.getGson().fromJson(json, JsonJsonModel.class);
    for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet())
    {
        if (entry.getKey().equals("textures"))
        {
            Map<String, String> map = context.deserialize(entry.getValue(), Map.class);
            for (String o : map.keySet())
            {
                model.texMap.put(o, map.get(o));
            }
        }
    }
    return model;
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:20,代码来源:JsonModel.java

示例6: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public AbstractDXRAMComponentConfig deserialize(final JsonElement p_jsonElement, final Type p_type,
        final JsonDeserializationContext p_jsonDeserializationContext) {

    JsonObject jsonObj = p_jsonElement.getAsJsonObject();
    String className = jsonObj.get("m_class").getAsString();

    Class<?> clazz;
    try {
        clazz = Class.forName(className);
    } catch (final ClassNotFoundException ignore) {
        LOGGER.fatal("Could not find component config for class name '%s', check your config file", className);
        return null;
    }

    if (!clazz.getSuperclass().equals(AbstractDXRAMComponentConfig.class)) {
        // check if there is an "interface"/abstract class between DXRAMComponent and the instance to
        // create
        if (!clazz.getSuperclass().getSuperclass().equals(AbstractDXRAMComponentConfig.class)) {
            LOGGER.fatal("Class '%s' is not a subclass of AbstractDXRAMComponentConfig, check your config file", className);
            return null;
        }
    }

    return p_jsonDeserializationContext.deserialize(p_jsonElement, clazz);
}
 
开发者ID:hhu-bsinfo,项目名称:dxram,代码行数:27,代码来源:DXRAMGsonContext.java

示例7: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public ErrorResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
	try {
		return context.deserialize(json, NormalErrorResponse.class);
	} catch (JsonParseException normal) {
		try {
			return context.deserialize(json, AdvancedErrorResponse.class);
		} catch (JsonParseException advanced) {
			throw new BothAttemptsFailedException(normal, advanced);
		}
	}
}
 
开发者ID:LogicalOverflow,项目名称:java-champion-gg-wrapper,代码行数:13,代码来源:ErrorResponseDeserializer.java

示例8: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
public PackMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    IChatComponent ichatcomponent = (IChatComponent)p_deserialize_3_.deserialize(jsonobject.get("description"), IChatComponent.class);

    if (ichatcomponent == null)
    {
        throw new JsonParseException("Invalid/missing description!");
    }
    else
    {
        int i = JsonUtils.getInt(jsonobject, "pack_format");
        return new PackMetadataSection(ichatcomponent, i);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:16,代码来源:PackMetadataSectionSerializer.java

示例9: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
public ModelBlock deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    List<BlockPart> list = this.getModelElements(p_deserialize_3_, jsonobject);
    String s = this.getParent(jsonobject);
    boolean flag = StringUtils.isEmpty(s);
    boolean flag1 = list.isEmpty();

    if (flag1 && flag)
    {
        throw new JsonParseException("BlockModel requires either elements or parent, found neither");
    }
    else if (!flag && !flag1)
    {
        throw new JsonParseException("BlockModel requires either elements or parent, found both");
    }
    else
    {
        Map<String, String> map = this.getTextures(jsonobject);
        boolean flag2 = this.getAmbientOcclusionEnabled(jsonobject);
        ItemCameraTransforms itemcameratransforms = ItemCameraTransforms.DEFAULT;

        if (jsonobject.has("display"))
        {
            JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonobject, "display");
            itemcameratransforms = (ItemCameraTransforms)p_deserialize_3_.deserialize(jsonobject1, ItemCameraTransforms.class);
        }

        return flag1 ? new ModelBlock(new ResourceLocation(s), map, flag2, true, itemcameratransforms) : new ModelBlock(list, map, flag2, true, itemcameratransforms);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:32,代码来源:ModelBlock.java

示例10: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public GenericZoneCapabilities deserialize(JsonElement json, Type type, JsonDeserializationContext context) {
    TadoSystemType settingType = TadoSystemType.valueOf(json.getAsJsonObject().get("type").getAsString());

    if (settingType == TadoSystemType.HEATING) {
        return context.deserialize(json, HeatingCapabilities.class);
    } else if (settingType == TadoSystemType.AIR_CONDITIONING) {
        return context.deserialize(json, AirConditioningCapabilities.class);
    } else if (settingType == TadoSystemType.HOT_WATER) {
        return context.deserialize(json, HotWaterCapabilities.class);
    }

    return null;
}
 
开发者ID:dfrommi,项目名称:openhab-tado,代码行数:15,代码来源:ZoneCapabilitiesConverter.java

示例11: deserializeClass

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
public static <T> T deserializeClass(@Nullable JsonElement json, String memberName, JsonDeserializationContext context, Class <? extends T > adapter)
{
    if (json != null)
    {
        return context.deserialize(json, adapter);
    }
    else
    {
        throw new JsonSyntaxException("Missing " + memberName);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:JsonUtils.java

示例12: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
public BlockPartFace deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    EnumFacing enumfacing = this.parseCullFace(jsonobject);
    int i = this.parseTintIndex(jsonobject);
    String s = this.parseTexture(jsonobject);
    BlockFaceUV blockfaceuv = (BlockFaceUV)p_deserialize_3_.deserialize(jsonobject, BlockFaceUV.class);
    return new BlockPartFace(enumfacing, i, s, blockfaceuv);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:10,代码来源:BlockPartFace.java

示例13: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public ListenNowItem deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException {
  JsonObject content = je.getAsJsonObject();
  if (content.has("album")) {
    addSubEntries(content, content.getAsJsonObject("album"));
    return jdc.deserialize(content, ListenNowAlbum.class);
  }
  if (content.has("radio_station")) {
    addSubEntries(content, content.getAsJsonObject("radio_station"));
    return jdc.deserialize(content, ListenNowStation.class);
  }
  throw new JsonParseException(Language.get("listenNowItem.UnknownType"));
}
 
开发者ID:FelixGail,项目名称:gplaymusic,代码行数:14,代码来源:ListenNowItemDeserializer.java

示例14: deserialize

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
@Override
public SearchDialogsResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonArray array = json.getAsJsonArray();

    SearchDialogsResponse response = new SearchDialogsResponse();

    List<SearchDialogsResponse.AbsChattable> list = new ArrayList<>(array.size());

    for(int i = 0; i < array.size(); i++){
        JsonObject object = array.get(i).getAsJsonObject();
        String type = object.get("type").getAsString();

        if("profile".equals(type)){
            VKApiUser user = context.deserialize(object, VKApiUser.class);
            list.add(new SearchDialogsResponse.User(user));
        } else if("group".equals(type) || "page".equals(type) || "event".equals(type)){
            VKApiCommunity community = context.deserialize(object, VKApiCommunity.class);
            list.add(new SearchDialogsResponse.Community(community));
        } else if("chat".equals(type)){
            VKApiChat chat = context.deserialize(object, VKApiChat.class);
            list.add(new SearchDialogsResponse.Chat(chat));
        }
    }

    response.setData(list);
    return response;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:28,代码来源:SearchDialogsResponseAdapter.java

示例15: parse

import com.google.gson.JsonDeserializationContext; //导入方法依赖的package包/类
private VKApiAttachment parse(String type, JsonObject root, JsonDeserializationContext context){
    JsonElement o = root.get(type);

    //{"type":"photos_list","photos_list":["406536042_456239026"]}

    if (VkApiAttachments.TYPE_PHOTO.equals(type)) {
        return context.deserialize(o, VKApiPhoto.class);
    } else if (VkApiAttachments.TYPE_VIDEO.equals(type)) {
        return context.deserialize(o, VKApiVideo.class);
    } else if (VkApiAttachments.TYPE_AUDIO.equals(type)) {
        return context.deserialize(o, VKApiAudio.class);
    } else if (VkApiAttachments.TYPE_DOC.equals(type)) {
        return context.deserialize(o, VkApiDoc.class);
    } else if (VkApiAttachments.TYPE_POST.equals(type)) {
        return context.deserialize(o, VKApiPost.class);
    //} else if (VkApiAttachments.TYPE_POSTED_PHOTO.equals(type)) {
    //    return context.deserialize(o, VKApiPostedPhoto.class);
    } else if (VkApiAttachments.TYPE_LINK.equals(type)) {
        return context.deserialize(o, VKApiLink.class);
    //} else if (VkApiAttachments.TYPE_NOTE.equals(type)) {
    //    return context.deserialize(o, VKApiNote.class);
    //} else if (VkApiAttachments.TYPE_APP.equals(type)) {
    //    return context.deserialize(o, VKApiApplicationContent.class);
    } else if (VkApiAttachments.TYPE_POLL.equals(type)) {
        return context.deserialize(o, VKApiPoll.class);
    } else if (VkApiAttachments.TYPE_WIKI_PAGE.equals(type)) {
        return context.deserialize(o, VKApiWikiPage.class);
    //} else if (VkApiAttachments.TYPE_ALBUM.equals(type)) {
    //    return context.deserialize(o, VKApiPhotoAlbum.class); // not supported yet
    } else if (VkApiAttachments.TYPE_STICKER.equals(type)) {
        return context.deserialize(o, VKApiSticker.class);
    }

    return null;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:36,代码来源:AttachmentsDtoAdapter.java


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