微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

com.google.gson.JsonDeserializationContext的实例源码

项目:VoxelGamesLibv2    文件FeatureTypeAdapter.java   
@Override
@Nullable
public Feature deserialize(@Nonnull JsonElement json,@Nonnull Type typeOfT,@Nonnull JsonDeserializationContext context)
        throws JsonParseException {
    try {
        JsonObject jsonObject = json.getAsJsonObject();

        // default path
        String name = jsonObject.get("name").getAsstring();
        if (!name.contains(".")) {
            name = DEFAULT_PATH + "." + name;
        }

        Class clazz = Class.forName(name);
        Feature feature = context.deserialize(json,clazz);
        injector.injectMembers(feature);
        return feature;
    } catch (Exception e) {
        log.log(Level.WARNING,"Could not deserialize feature:\n" + json.toString(),e);
    }
    return null;
}
项目:CustomWorldGen    文件SetAttributes.java   
public SetAttributes deserialize(JsonObject object,JsonDeserializationContext deserializationContext,LootCondition[] conditionsIn)
{
    JsonArray jsonarray = JsonUtils.getJsonArray(object,"modifiers");
    SetAttributes.Modifier[] asetattributes$modifier = new SetAttributes.Modifier[jsonarray.size()];
    int i = 0;

    for (JsonElement jsonelement : jsonarray)
    {
        asetattributes$modifier[i++] = SetAttributes.Modifier.deserialize(JsonUtils.getJsonObject(jsonelement,"modifier"),deserializationContext);
    }

    if (asetattributes$modifier.length == 0)
    {
        throw new JsonSyntaxException("Invalid attribute modifiers array; cannot be empty");
    }
    else
    {
        return new SetAttributes(conditionsIn,asetattributes$modifier);
    }
}
项目:CustomWorldGen    文件VariantList.java   
public VariantList deserialize(JsonElement p_deserialize_1_,Type p_deserialize_2_,JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    List<Variant> list = Lists.<Variant>newArrayList();

    if (p_deserialize_1_.isJsonArray())
    {
        JsonArray jsonarray = p_deserialize_1_.getAsJsonArray();

        if (jsonarray.size() == 0)
        {
            throw new JsonParseException("Empty variant array");
        }

        for (JsonElement jsonelement : jsonarray)
        {
            list.add((Variant)p_deserialize_3_.deserialize(jsonelement,Variant.class));
        }
    }
    else
    {
        list.add((Variant)p_deserialize_3_.deserialize(p_deserialize_1_,Variant.class));
    }

    return new VariantList(list);
}
项目:CustomWorldGen    文件ModelBlockDeFinition.java   
protected Map<String,VariantList> parseMapVariants(JsonDeserializationContext deserializationContext,JsonObject object)
{
    Map<String,VariantList> map = Maps.<String,VariantList>newHashMap();

    if (object.has("variants"))
    {
        JsonObject jsonobject = JsonUtils.getJsonObject(object,"variants");

        for (Entry<String,JsonElement> entry : jsonobject.entrySet())
        {
            map.put(entry.getKey(),(VariantList)deserializationContext.deserialize((JsonElement)entry.getValue(),VariantList.class));
        }
    }

    return map;
}
项目:android-mvvm-Example    文件VideoListDeserializer.java   
@Override
public VideoList deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context)
        throws JsonParseException {

    VideoList videoList = new VideoList();

    JsonObject jsonObject = json.getAsJsonObject().getAsJsonObject("data");
    videoList.setAfter(jsonObject.getAsJsonPrimitive("after").getAsstring());

    Iterator<JsonElement> videoListJsonIterator = jsonObject.getAsJsonArray("children").iterator();
    while (videoListJsonIterator.hasNext()) {
        JsonElement videoItemJson = videoListJsonIterator.next();
        try {
            Video video = context.deserialize(videoItemJson,Video.class);
            if (video != null) {
                videoList.addVideo(video);
            }
        } catch (Throwable t) {
            Log.e(TAG,"Failed to deserialize a video item : " + videoItemJson,t);
        }
    }

    return videoList;
}
项目:android-mvvm-Example    文件VideoDeserializer.java   
@Override
public Video deserialize(JsonElement json,JsonDeserializationContext context)
        throws JsonParseException {

    Video video = null;

    JsonObject jsonObject = json.getAsJsonObject().getAsJsonObject("data");
    String domain = jsonObject.getAsJsonPrimitive("domain").getAsstring();

    if (isYoutubedomain(domain)) {
        String url = jsonObject.getAsJsonPrimitive("url").getAsstring();
        String youtubeId = getYoutubeId(url);
        if (youtubeId != null && youtubeId.length() > 0) {
            video = new Video(
                    jsonObject.getAsJsonPrimitive("id").getAsstring(),youtubeId,jsonObject.getAsJsonPrimitive("created").getAsLong(),jsonObject.getAsJsonPrimitive("title").getAsstring(),url
            );
        }
    }

    return video;
}
项目:Phoenix-for-VK    文件FeedbackUserArrayDtoAdapter.java   
@Override
public UserArray deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {
    JsonObject root = json.getAsJsonObject();
    UserArray dto = new UserArray();

    dto.count = optInt(root,"count");

    if(root.has("items")){
        JsonArray array = root.getAsJsonArray("items");
        dto.ids = new int[array.size()];

        for(int i = 0; i < array.size(); i++){
            dto.ids[i] = array.get(i).getAsJsonObject().get("from_id").getAsInt();
        }
    } else {
        dto.ids = new int[0];
    }

    return dto;
}
项目:buckaroo    文件UrlDeserializer.java   
@Override
public URL deserialize(final JsonElement jsonElement,final Type type,final JsonDeserializationContext context) throws JsonParseException {

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

    if (jsonElement.getAsstring() == null) {
        throw new JsonParseException("URL must be a string");
    }

    try {
        return new URL(jsonElement.getAsstring());
    } catch (final MalformedURLException e) {
        throw new JsonParseException(e);
    }
}
项目:ultimate-geojson    文件FeatureCollectionDeserializer.java   
@Override
public FeatureCollectionDto deserialize(JsonElement json,JsonDeserializationContext context) {

    FeatureCollectionDto dto = new FeatureCollectionDto();
    List<FeatureDto> features = new ArrayList<>();
    dto.setFeatures(features);

    JsonObject asJsonObject = json.getAsJsonObject();
    JsonArray jsonArray = asJsonObject.get("features").getAsJsonArray();
    if (jsonArray == null) {
        return dto;
    }

    for (int i = 0; i < jsonArray.size(); i++) {
        JsonObject featureElement = jsonArray.get(i).getAsJsonObject();
        FeatureDto geometryDto = context.deserialize(featureElement,FeatureDto.class);
        features.add(geometryDto);
    }

    dto.setBBox(BoundingBoxParser.parseBBox(asJsonObject,context));

    return dto;
}
项目:Decompiledminecraft    文件ModelBlockDeFinition.java   
protected ModelBlockDeFinition.Variants parseVariants(JsonDeserializationContext p_178335_1_,Entry<String,JsonElement> p_178335_2_)
{
    String s = (String)p_178335_2_.getKey();
    List<ModelBlockDeFinition.Variant> list = Lists.<ModelBlockDeFinition.Variant>newArrayList();
    JsonElement jsonelement = (JsonElement)p_178335_2_.getValue();

    if (jsonelement.isJsonArray())
    {
        for (JsonElement jsonelement1 : jsonelement.getAsJsonArray())
        {
            list.add((ModelBlockDeFinition.Variant)p_178335_1_.deserialize(jsonelement1,ModelBlockDeFinition.Variant.class));
        }
    }
    else
    {
        list.add((ModelBlockDeFinition.Variant)p_178335_1_.deserialize(jsonelement,ModelBlockDeFinition.Variant.class));
    }

    return new ModelBlockDeFinition.Variants(s,list);
}
项目:dxram    文件ApplicationGsonContext.java   
@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);
}
项目:Phoenix-for-VK    文件DboWrapperAdapter.java   
@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);
}
项目:Phoenix-for-VK    文件AttachmentsDboAdapter.java   
@Override
public AttachmentsEntity deserialize(JsonElement jsonElement,Type type,JsonDeserializationContext context) throws JsonParseException {
    JsonArray array = jsonElement.getAsJsonArray();

    if(array.size() == 0){
        return new AttachmentsEntity(Collections.emptyList());
    }

    List<Entity> entities = new ArrayList<>(array.size());

    for(int i = 0; i < array.size(); i++){
        JsonObject o = array.get(i).getAsJsonObject();
        int dbotype = o.get(KEY_ENTITY_TYPE).getAsInt();
        entities.add(context.deserialize(o.get(KEY_ENTITY),AttachmentsTypes.classForType(dbotype)));
    }

    return new AttachmentsEntity(entities);
}
项目:SwitchBoxPlugin    文件FieldMapDeserializer.java   
@Override
public FieldMap deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {
    JsonObject rootObject = json.getAsJsonObject();

    Set<Map.Entry<String,JsonElement>> entrySet = rootObject.entrySet();

    FieldMap fieldMap = new FieldMap();
    for (Map.Entry<String,JsonElement> entry : entrySet) {
        JsonObject propertyObject = entry.getValue().getAsJsonObject();
        String propertyName = entry.getKey();

        parsePropertyObject(propertyObject,propertyName,fieldMap,context);
    }

    return fieldMap;
}
项目:Decompiledminecraft    文件ServerStatusResponse.java   
public ServerStatusResponse.PlayerCountData deserialize(JsonElement p_deserialize_1_,JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_,"players");
    ServerStatusResponse.PlayerCountData serverstatusresponse$playercountdata = new ServerStatusResponse.PlayerCountData(JsonUtils.getInt(jsonobject,"max"),JsonUtils.getInt(jsonobject,"online"));

    if (JsonUtils.isJsonArray(jsonobject,"sample"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject,"sample");

        if (jsonarray.size() > 0)
        {
            GameProfile[] agameprofile = new GameProfile[jsonarray.size()];

            for (int i = 0; i < agameprofile.length; ++i)
            {
                JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i),"player[" + i + "]");
                String s = JsonUtils.getString(jsonobject1,"id");
                agameprofile[i] = new GameProfile(UUID.fromString(s),JsonUtils.getString(jsonobject1,"name"));
            }

            serverstatusresponse$playercountdata.setPlayers(agameprofile);
        }
    }

    return serverstatusresponse$playercountdata;
}
项目:RoadLab-Pro    文件RestClient.java   
private Retrofit getRetrofitInstance() {
    if (retrofit == null) {
        Gson gson = new GsonBuilder()
                .registerTypeAdapter(Date.class,new JsonDeserializer<Date>() {
                    public Date deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {
                        return new Date(json.getAsJsonPrimitive().getAsLong());
                    }
                })
                .setPrettyPrinting()
                .create();

        retrofit = new Retrofit.Builder()
                .client(getUnsafeOkHttpClient())
                .baseUrl(Constants.GOOGLE_BASE_URL)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();
        retrofit.client().interceptors().add(new RequestInterceptor());
    }
    return retrofit;
}
项目:Backmemed    文件LootEntryItem.java   
public static LootEntryItem deserialize(JsonObject object,int weightIn,int qualityIn,LootCondition[] conditionsIn)
{
    Item item = JsonUtils.getItem(object,"name");
    LootFunction[] alootfunction;

    if (object.has("functions"))
    {
        alootfunction = (LootFunction[])JsonUtils.deserializeClass(object,"functions",deserializationContext,LootFunction[].class);
    }
    else
    {
        alootfunction = new LootFunction[0];
    }

    return new LootEntryItem(item,weightIn,qualityIn,alootfunction,conditionsIn);
}
项目:VoxelGamesLibv2    文件GameTypeAdapter.java   
@Override
@Nullable
public Phase deserialize(@Nonnull JsonElement json,@Nonnull JsonDeserializationContext context) throws JsonParseException {
    try {
        JsonObject jsonObject = json.getAsJsonObject();

        // default path
        String name = jsonObject.get("className").getAsstring();

        Class clazz = Class.forName(name);
        Phase phase = context.deserialize(json,clazz);
        injector.injectMembers(phase);
        return phase;
    } catch (Exception e) {
        log.log(Level.WARNING,"Could not deserialize phase:\n" + json.toString(),e);
    }
    return null;
}
项目:CustomWorldGen    文件LootConditionManager.java   
public LootCondition deserialize(JsonElement p_deserialize_1_,"condition");
    ResourceLocation resourcelocation = new ResourceLocation(JsonUtils.getString(jsonobject,"condition"));
    LootCondition.Serializer<?> serializer;

    try
    {
        serializer = LootConditionManager.getSerializerForName(resourcelocation);
    }
    catch (IllegalArgumentException var8)
    {
        throw new JsonSyntaxException("UnkNown condition \'" + resourcelocation + "\'");
    }

    return serializer.deserialize(jsonobject,p_deserialize_3_);
}
项目:Backmemed    文件LootEntry.java   
public LootEntry deserialize(JsonElement p_deserialize_1_,"loot item");
    String s = JsonUtils.getString(jsonobject,"type");
    int i = JsonUtils.getInt(jsonobject,"weight",1);
    int j = JsonUtils.getInt(jsonobject,"quality",0);
    LootCondition[] alootcondition;

    if (jsonobject.has("conditions"))
    {
        alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject,"conditions",p_deserialize_3_,LootCondition[].class);
    }
    else
    {
        alootcondition = new LootCondition[0];
    }

    if ("item".equals(s))
    {
        return LootEntryItem.deserialize(jsonobject,i,j,alootcondition);
    }
    else if ("loot_table".equals(s))
    {
        return LootEntryTable.deserialize(jsonobject,alootcondition);
    }
    else if ("empty".equals(s))
    {
        return LootEntryEmpty.deserialize(jsonobject,alootcondition);
    }
    else
    {
        throw new JsonSyntaxException("UnkNown loot entry type \'" + s + "\'");
    }
}
项目:gplaymusic    文件ResultDeserializer.java   
@Override
public Result deserialize(JsonElement je,JsonDeserializationContext jdc)
    throws JsonParseException {
  JsonObject content = je.getAsJsonObject();
  ResultType resultType = jdc.deserialize(content.get("type"),ResultType.class);
  return jdc.deserialize(content.get(resultType.getName()),resultType.getType());
}
项目:openhab-tado    文件OverlayTerminationConditionTemplateConverter.java   
@Override
public OverlayTerminationConditionTemplate deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {

    OverlayTerminationConditionType terminationType = OverlayTerminationConditionType
            .valueOf(json.getAsJsonObject().get("type").getAsstring());

    if (terminationType == OverlayTerminationConditionType.TIMER) {
        return context.deserialize(json,TimerTerminationConditionTemplate.class);
    }

    // no converter,otherwise stackoverflow
    return new GsonBuilder().create().fromJson(json,OverlayTerminationConditionTemplate.class);
}
项目:CustomWorldGen    文件RandomValueRange.java   
public RandomValueRange deserialize(JsonElement p_deserialize_1_,JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    if (JsonUtils.isNumber(p_deserialize_1_))
    {
        return new RandomValueRange(JsonUtils.getFloat(p_deserialize_1_,"value"));
    }
    else
    {
        JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_,"value");
        float f = JsonUtils.getFloat(jsonobject,"min");
        float f1 = JsonUtils.getFloat(jsonobject,"max");
        return new RandomValueRange(f,f1);
    }
}
项目:openhab-tado    文件ZonesettingConverter.java   
@Override
public GenericZonesetting deserialize(JsonElement json,JsonDeserializationContext context) {

    TadoSystemType settingType = TadoSystemType.valueOf(json.getAsJsonObject().get("type").getAsstring());

    if (settingType == TadoSystemType.HEATING) {
        return context.deserialize(json,HeatingzoneSetting.class);
    } else if (settingType == TadoSystemType.HOT_WATER) {
        return context.deserialize(json,HotWaterZonesetting.class);
    } else if (settingType == TadoSystemType.AIR_CONDITIONING) {
        return context.deserialize(json,CoolingzoneSetting.class);
    }

    return null;
}
项目:arquillian-reporter    文件ReportJsonDeserializer.java   
private Report parseExecutionReport(JsonObject jsonReport,JsonDeserializationContext context){
    ExecutionReport executionReport = new ExecutionReport();

    JsonArray testSuiteReportsJson = jsonReport.get("testSuiteReports").getAsJsonArray();
    testSuiteReportsJson.forEach(suite -> {
        Report testSuiteReport = prepareGsonParser().fromJson(suite,TestSuiteReport.class);
        executionReport.getTestSuiteReports().add((TestSuiteReport) testSuiteReport);
    });

    return setDefaultValues(executionReport,jsonReport);
}
项目:Backmemed    文件BlockPartFace.java   
public BlockPartFace deserialize(JsonElement p_deserialize_1_,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,s,blockfaceuv);
}
项目:jSpace    文件TupleDeserializer.java   
@Override
public Tuple deserialize(JsonElement json,JsonDeserializationContext context)
        throws JsonParseException {
    if (!json.isJsonArray()) {
        throw new JsonParseException("Unexpected JsonElement!");
    }
    JsonArray jsa = (JsonArray) json;
    Object[] data = new Object[jsa.size()];
    jSonUtils util = jSonUtils.getInstance();
    for (int i = 0; i < jsa.size(); i++) {
        data[i] = util.objectFromJson(jsa.get(i),context);
    }
    return new Tuple(data);
}
项目:OSchina_resources_android    文件FloatJsonDeserializer.java   
@Override
public Float deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {
    try {
        return json.getAsFloat();
    } catch (Exception e) {
        TLog.log("FloatJsonDeserializer-deserialize-error:" + (json != null ? json.toString() : ""));
        return 0F;
    }
}
项目:OpenDiabetes    文件VaultEntryGsonAdapter.java   
@Override
public VaultEntry deserialize(JsonElement je,JsonDeserializationContext jdc) throws JsonParseException {
    JsonObject obj = je.getAsJsonObject();
    VaultEntry entry = new VaultEntry(
            VaultEntryType.values()[obj.get("tp").getAsInt()],new Date(obj.get("ts").getAsLong()),obj.get("v1").getAsDouble(),obj.get("v1").getAsDouble());
    entry.setAnnotaionFromJson(obj.get("at").getAsstring());

    return entry;
}
项目:bittrex-api-wrapper    文件BittrexDateGsonTypeAdapter.java   
@Override
public Date deserialize(JsonElement element,JsonDeserializationContext context)
        throws JsonParseException {
    final StringBuilder patternBuilder = new StringBuilder("yyyy-MM-dd'T'HH:mm:s");
    final int strLength = element.getAsstring().length();
    if(strLength > 18) {
        final String[] secondsAndMillis = element.getAsstring().split("T")[1].split(":")[2].split("\\.");
        final int secondsDigitCount = secondsAndMillis[0].length();
        if(secondsDigitCount > 1) {
            patternBuilder.append("s");
        }

        if(secondsAndMillis.length > 1) {
            for(int i = 0; i < secondsAndMillis[1].length(); i++) {
                patternBuilder.append(i > 0 ? "S" : ".S");
            }
        }
    }

    final String pattern = patternBuilder.toString();
    final DateFormat format = new SimpleDateFormat(pattern);
    try {
        return format.parse(element.getAsstring());
    } catch (ParseException e) {
        throw new JsonParseException(
                String.format("'%s' Could not be parsed using pattern '%s'",element.getAsstring(),pattern),e);
    }
}
项目:Uranium    文件TranslatableComponentSerializer.java   
@Override
public TranslatableComponent deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {
    TranslatableComponent component = new TranslatableComponent();
    JsonObject object = json.getAsJsonObject();
    this.deserialize(object,component,context);
    component.setTranslate(object.get("translate").getAsstring());
    if (object.has("with")) {
        component.setWith(Arrays.asList((BaseComponent[])context.deserialize(object.get("with"),BaseComponent[].class)));
    }
    return component;
}
项目:hypertrack-live-android    文件DateDeserializer.java   
@Override
public Date deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {
    try {
        return json == null ? null : new Date(json.getAsLong());

    } catch (NumberFormatException e) {
        CrashlyticsWrapper.log(e);
        e.printstacktrace();

        return deserialize12HourDateFormatString(json.getAsstring());
    }
}
项目:ultimate-geojson    文件FeatureDeserializer.java   
@Override
public FeatureDto deserialize(JsonElement json,JsonDeserializationContext context) {

    FeatureDto dto = new FeatureDto();

    JsonObject asJsonObject = json.getAsJsonObject();
    JsonElement geometryElement = asJsonObject.get("geometry");
    if (geometryElement != null) {
        String typeOfGeometry = geometryElement.getAsJsonObject().get("type").getAsstring();
        GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry);
        GeometryDto geometryDto = context.deserialize(geometryElement,typeEnum.getDtoClass());
        dto.setGeometry(geometryDto);

    }

    JsonElement propertiesJsonElement = asJsonObject.get("properties");
    if (propertiesJsonElement != null) {
        dto.setProperties(propertiesJsonElement.toString());
    }

    JsonElement idJsonElement = asJsonObject.get("id");
    if (idJsonElement != null) {
        dto.setId(idJsonElement.getAsstring());
    }

    dto.setBBox(BoundingBoxParser.parseBBox(asJsonObject,context));

    return dto;
}
项目:CustomWorldGen    文件ItemTransformVec3f.java   
public ItemTransformVec3f deserialize(JsonElement p_deserialize_1_,JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    Vector3f vector3f = this.parseVector3f(jsonobject,"rotation",ROTATION_DEFAULT);
    Vector3f vector3f1 = this.parseVector3f(jsonobject,"translation",TRANSLATION_DEFAULT);
    vector3f1.scale(0.0625F);
    vector3f1.x = MathHelper.clamp_float(vector3f1.x,-5.0F,5.0F);
    vector3f1.y = MathHelper.clamp_float(vector3f1.y,5.0F);
    vector3f1.z = MathHelper.clamp_float(vector3f1.z,5.0F);
    Vector3f vector3f2 = this.parseVector3f(jsonobject,"scale",SCALE_DEFAULT);
    vector3f2.x = MathHelper.clamp_float(vector3f2.x,-4.0F,4.0F);
    vector3f2.y = MathHelper.clamp_float(vector3f2.y,4.0F);
    vector3f2.z = MathHelper.clamp_float(vector3f2.z,4.0F);
    return new ItemTransformVec3f(vector3f,vector3f1,vector3f2);
}
项目:BaseClient    文件ModelBlockDeFinition.java   
protected List<ModelBlockDeFinition.Variants> parseVariantsList(JsonDeserializationContext p_178334_1_,JsonObject p_178334_2_)
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_178334_2_,"variants");
    List<ModelBlockDeFinition.Variants> list = Lists.<ModelBlockDeFinition.Variants>newArrayList();

    for (Entry<String,JsonElement> entry : jsonobject.entrySet())
    {
        list.add(this.parseVariants(p_178334_1_,entry));
    }

    return list;
}
项目:Decompiledminecraft    文件ModelBlockDeFinition.java   
public ModelBlockDeFinition.Variant deserialize(JsonElement p_deserialize_1_,JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    String s = this.parseModel(jsonobject);
    ModelRotation modelrotation = this.parseRotation(jsonobject);
    boolean flag = this.parseUvLock(jsonobject);
    int i = this.parseWeight(jsonobject);
    return new ModelBlockDeFinition.Variant(this.makeModelLocation(s),modelrotation,flag,i);
}
项目:gplaymusic    文件ConfigDeserializer.java   
@Override
public Config deserialize(JsonElement je,JsonDeserializationContext jdc)
    throws JsonParseException {
  JsonObject content = je.getAsJsonObject();
  Config config = new Config();
  JsonArray entries = content.getAsJsonObject("data").getAsJsonArray("entries");
  for (JsonElement entry : entries) {
    JsonObject o = entry.getAsJsonObject();
    config.put(o.get("key").getAsstring(),o.get("value").getAsstring());
  }
  return config;
}
项目:openhab-tado    文件ZoneCapabilitiesConverter.java   
@Override
public GenericZoneCapabilities deserialize(JsonElement json,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;
}
项目:nifi-atlas    文件NiFiapiclient.java   
@Override
public Date deserialize(JsonElement jsonElement,JsonDeserializationContext context)
        throws com.google.gson.JsonParseException {
    for (String format : FORMATS) {
        try {
            return new SimpleDateFormat(format).parse(jsonElement.getAsstring());
        } catch (ParseException e) {
            // Try next format.
        }
    }
    throw new JsonParseException("Failed to parse " + jsonElement + " to Date.");
}
项目:Phoenix-for-VK    文件CommentDtoAdapter.java   
@Override
public VKApiComment deserialize(JsonElement json,JsonDeserializationContext context) throws JsonParseException {
    JsonObject root = json.getAsJsonObject();
    VKApiComment dto = new VKApiComment();

    dto.id = optInt(root,"id");
    dto.from_id = optInt(root,"from_id");

    if(dto.from_id == 0){
        dto.from_id = optInt(root,"owner_id");
    }

    dto.date = optLong(root,"date");
    dto.text = optString(root,"text");
    dto.reply_to_user = optInt(root,"reply_to_user");
    dto.reply_to_comment = optInt(root,"reply_to_comment");

    if(root.has("attachments")){
        dto.attachments = context.deserialize(root.get("attachments"),VkApiAttachments.class);
    }

    if(root.has("likes")){
        JsonObject likesRoot = root.getAsJsonObject("likes");
        dto.likes = optInt(likesRoot,"count");
        dto.user_likes = optIntAsBoolean(likesRoot,"user_likes");
        dto.can_like = optIntAsBoolean(likesRoot,"can_like");
    }

    dto.can_edit = optIntAsBoolean(root,"can_edit");
    return dto;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。