Java 类com.google.gson.JsonParseException 实例源码
项目:Ghost-Android
文件:DateDeserializer.java
@Override
public Date deserialize(JsonElement element, Type type, JsonDeserializationContext context)
throws JsonParseException {
String date = element.getAsString();
@SuppressLint("SimpleDateFormat")
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
return formatter.parse(date);
} catch (ParseException e) {
Log.e(TAG, "Date parsing failed");
Log.exception(e);
return new Date();
}
}
项目:ja-micro
文件:ProtobufUtil.java
private static boolean isValidJSON(String input) {
if (StringUtils.isBlank(input)) {
logger.warn("Parsing empty json string to protobuf is deprecated and will be removed in " +
"the next major release");
return false;
}
if (!input.startsWith("{")) {
logger.warn("Parsing json string that does not start with { is deprecated and will be " +
"removed in the next major release");
return false;
}
try {
new JsonParser().parse(input);
} catch (JsonParseException ex) {
return false;
}
return true;
}
项目:BittrexApi
文件:DefaultDateTypeAdapter.java
@Override
public Date read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
if (in.peek() != JsonToken.STRING) {
throw new JsonParseException("The date should be a string value");
}
Date date = deserializeToDate(in.nextString());
if (dateType == Date.class) {
return date;
} else if (dateType == Timestamp.class) {
return new Timestamp(date.getTime());
} else if (dateType == java.sql.Date.class) {
return new java.sql.Date(date.getTime());
} else {
// This must never happen: dateType is guarded in the primary constructor
throw new AssertionError();
}
}
项目:boohee_v5.6
文件:Streams.java
public static JsonElement parse(JsonReader reader) throws JsonParseException {
boolean isEmpty = true;
try {
reader.peek();
isEmpty = false;
return (JsonElement) TypeAdapters.JSON_ELEMENT.read(reader);
} catch (Throwable e) {
if (isEmpty) {
return JsonNull.INSTANCE;
}
throw new JsonSyntaxException(e);
} catch (Throwable e2) {
throw new JsonSyntaxException(e2);
} catch (Throwable e22) {
throw new JsonIOException(e22);
} catch (Throwable e222) {
throw new JsonSyntaxException(e222);
}
}
项目:Phoenix-for-VK
文件:AttachmentsDtoAdapter.java
@Override
public VkApiAttachments deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonArray array = json.getAsJsonArray();
VkApiAttachments dto = new VkApiAttachments();
dto.entries = new ArrayList<>(array.size());
for(int i = 0; i < array.size(); i++){
JsonObject o = array.get(i).getAsJsonObject();
String type = optString(o, "type");
VKApiAttachment attachment = parse(type, o, context);
if(Objects.nonNull(attachment)){
dto.entries.add(new VkApiAttachments.Entry(type, attachment));
}
}
return dto;
}
项目:CustomWorldGen
文件:ForgeBlockStateV1.java
public static Matrix4f parseMatrix(JsonElement e)
{
if (!e.isJsonArray()) throw new JsonParseException("Matrix: expected an array, got: " + e);
JsonArray m = e.getAsJsonArray();
if (m.size() != 3) throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size());
Matrix4f ret = new Matrix4f();
for (int i = 0; i < 3; i++)
{
if (!m.get(i).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(i));
JsonArray r = m.get(i).getAsJsonArray();
if (r.size() != 4) throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size());
for (int j = 0; j < 4; j++)
{
try
{
ret.setElement(i, j, r.get(j).getAsNumber().floatValue());
}
catch (ClassCastException ex)
{
throw new JsonParseException("Matrix element: expected number, got: " + r.get(j));
}
}
}
return ret;
}
项目:OSchina_resources_android
文件:ImageJsonDeserializer.java
@Override
public Tweet.Image deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
try {
if (json.isJsonObject()) {
Tweet.Image image = new Tweet.Image();
// The whole object is available
final JsonObject jsonObject = json.getAsJsonObject();
image.setThumb(context.<String>deserialize(jsonObject.get("thumb"), String.class));
image.setHref(context.<String>deserialize(jsonObject.get("href"), String.class));
image.setH(context.<Integer>deserialize(jsonObject.get("h"), int.class));
image.setW(context.<Integer>deserialize(jsonObject.get("w"), int.class));
if (Tweet.Image.check(image))
return image;
else
return null;
}
} catch (Exception e) {
TLog.error("ImageJsonDeserializer-deserialize-error:" + (json != null ? json.toString() : ""));
}
return null;
}
项目:ObsidianSuite
文件:JsonModel.java
@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;
}
项目:DecompiledMinecraft
文件:BlockPart.java
public BlockPart deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
Vector3f vector3f = this.parsePositionFrom(jsonobject);
Vector3f vector3f1 = this.parsePositionTo(jsonobject);
BlockPartRotation blockpartrotation = this.parseRotation(jsonobject);
Map<EnumFacing, BlockPartFace> map = this.parseFacesCheck(p_deserialize_3_, jsonobject);
if (jsonobject.has("shade") && !JsonUtils.isBoolean(jsonobject, "shade"))
{
throw new JsonParseException("Expected shade to be a Boolean");
}
else
{
boolean flag = JsonUtils.getBoolean(jsonobject, "shade", true);
return new BlockPart(vector3f, vector3f1, map, blockpartrotation, flag);
}
}
项目:arquillian-reporter
文件:EntryJsonDeserializer.java
@Override
public Entry deserialize(JsonElement json, Type type, JsonDeserializationContext jsonDeserializationContext)
throws JsonParseException {
JsonObject jsonEntry = (JsonObject) json;
JsonElement key = jsonEntry.get("key");
JsonElement content = jsonEntry.get("content");
JsonElement filePath = jsonEntry.get("filePath");
if (key != null) {
StringKey keyEntry = prepareGsonParser().fromJson(key, StringKey.class);
JsonElement value = jsonEntry.get("value");
if (value != null) {
return new KeyValueEntry(keyEntry, prepareGsonParser().fromJson(value, Entry.class));
}
} else if (content != null) {
StringKey stringEntry = prepareGsonParser().fromJson(content, StringKey.class);
return new StringEntry(stringEntry);
} else if (filePath != null) {
String fileEntry = prepareGsonParser().fromJson(filePath, String.class);
return new FileEntry(fileEntry);
}
return new StringEntry("");
}
项目:buckaroo
文件:ProjectSerializerTest.java
@org.junit.Test
public void testProjectSerializer1() throws Exception {
final Project project = Project.of(
Optional.of("my-magic-tool"),
Optional.of("my-magic-tool-lib"),
Optional.of("MIT"),
DependencyGroup.of(ImmutableMap.of(
RecipeIdentifier.of("org", "my-magic-lib"),
ExactSemanticVersion.of(SemanticVersion.of(4, 5, 6)),
RecipeIdentifier.of("org", "some-other-lib"),
ExactSemanticVersion.of(
SemanticVersion.of(4, 1),
SemanticVersion.of(4, 2)),
RecipeIdentifier.of("org", "awesome-lib"),
AnySemanticVersion.of())));
final String serializedProject = Serializers.serialize(project);
final Either<JsonParseException, Project> deserializedProject =
Serializers.parseProject(serializedProject);
assertEquals(Either.right(project), deserializedProject);
}
项目:open-rmbt
文件:ServerOption.java
@Override
public ServerOption deserialize(JsonElement json, Type arg1,
JsonDeserializationContext arg2) throws JsonParseException {
Gson gson = new Gson();
final ServerOption item = gson.fromJson(json, ServerOption.class);
setParentRecursive(item, null);
return item;
}
项目:DecompiledMinecraft
文件:PlayerProfileCache.java
/**
* Load the cached profiles from disk
*/
public void load()
{
BufferedReader bufferedreader = null;
try
{
bufferedreader = Files.newReader(this.usercacheFile, Charsets.UTF_8);
List<PlayerProfileCache.ProfileEntry> list = (List)this.gson.fromJson((Reader)bufferedreader, TYPE);
this.usernameToProfileEntryMap.clear();
this.uuidToProfileEntryMap.clear();
this.gameProfiles.clear();
for (PlayerProfileCache.ProfileEntry playerprofilecache$profileentry : Lists.reverse(list))
{
if (playerprofilecache$profileentry != null)
{
this.addEntry(playerprofilecache$profileentry.getGameProfile(), playerprofilecache$profileentry.getExpirationDate());
}
}
}
catch (FileNotFoundException var9)
{
;
}
catch (JsonParseException var10)
{
;
}
finally
{
IOUtils.closeQuietly((Reader)bufferedreader);
}
}
项目:DecompiledMinecraft
文件:PackMetadataSectionSerializer.java
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);
}
}
项目:GitHub
文件:ExceptionEngine.java
public static ApiException handleException(Throwable e) {
ApiException ex;
if (e instanceof HttpException) { //HTTP错误
HttpException httpExc = (HttpException) e;
ex = new ApiException(e, httpExc.code());
ex.setMsg("网络错误"); //均视为网络错误
return ex;
} else if (e instanceof ServerException) { //服务器返回的错误
ServerException serverExc = (ServerException) e;
ex = new ApiException(serverExc, serverExc.getCode());
ex.setMsg(serverExc.getMsg());
return ex;
} else if (e instanceof JsonParseException
|| e instanceof JSONException
|| e instanceof ParseException || e instanceof MalformedJsonException) { //解析数据错误
ex = new ApiException(e, ANALYTIC_SERVER_DATA_ERROR);
ex.setMsg("解析错误");
return ex;
} else if (e instanceof ConnectException) {//连接网络错误
ex = new ApiException(e, CONNECT_ERROR);
ex.setMsg("连接失败");
return ex;
} else if (e instanceof SocketTimeoutException) {//网络超时
ex = new ApiException(e, TIME_OUT_ERROR);
ex.setMsg("网络超时");
return ex;
} else { //未知错误
ex = new ApiException(e, UN_KNOWN_ERROR);
ex.setMsg("未知错误");
return ex;
}
}
项目:GitHub
文件:HolderJsonSerializer.java
@Override
public Holder deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
JsonObject root = (JsonObject) json;
ImmutableHolder.Builder builder = ImmutableHolder.builder();
if (root.has("id")) {
builder.id(root.get("id").getAsString());
}
JsonElement value = root.get(VALUE_PROPERTY);
if (value == null) {
throw new JsonParseException(String.format("%s not found for %s in JSON", VALUE_PROPERTY, type));
}
if (value.isJsonObject()) {
final String valueTypeName = value.getAsJsonObject().get(Holder.TYPE_PROPERTY).getAsString();
try {
Class<?> valueType = Class.forName(valueTypeName);
builder.value(context.deserialize(value, valueType));
} catch (ClassNotFoundException e) {
throw new JsonParseException(String.format("Couldn't construct value class %s for %s", valueTypeName, type), e);
}
} else if (value.isJsonPrimitive()) {
final JsonPrimitive primitive = value.getAsJsonPrimitive();
if (primitive.isString()) {
builder.value(primitive.getAsString());
} else if (primitive.isNumber()) {
builder.value(primitive.getAsInt());
} else if (primitive.isBoolean()) {
builder.value(primitive.getAsBoolean());
}
} else {
throw new JsonParseException(
String.format("Couldn't deserialize %s : %s. Not a primitive or object", VALUE_PROPERTY, value));
}
return builder.build();
}
项目:Clases-2017c1
文件:EventAdapter.java
@Override
public Event deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.get("reply_to") != null) {
return context.deserialize(json, ResponseEvent.class);
}
JsonElement typeObj = jsonObject.get("type");
String type = typeObj != null ? typeObj.getAsString() : null;
Class<? extends Event> clazz = classForType(type != null ? type : "unknown");
return context.deserialize(json, clazz);
}
项目:bullet-core
文件:AbstractQuery.java
/**
* Constructor that takes a String representation of the query and a configuration to use.
*
* @param queryString The query as a string.
* @param config The validated {@link BulletConfig} configuration to use.
* @throws ParsingException if there was an issue.
*/
public AbstractQuery(String queryString, BulletConfig config) throws JsonParseException, ParsingException {
this.queryString = queryString;
specification = Parser.parse(queryString, config);
Optional<List<Error>> errors = specification.validate();
if (errors.isPresent()) {
throw new ParsingException(errors.get());
}
duration = specification.getDuration();
startTime = System.currentTimeMillis();
}
项目:BaseClient
文件:BlockPart.java
private EnumFacing.Axis parseAxis(JsonObject p_178252_1_)
{
String s = JsonUtils.getString(p_178252_1_, "axis");
EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.byName(s.toLowerCase());
if (enumfacing$axis == null)
{
throw new JsonParseException("Invalid rotation axis: " + s);
}
else
{
return enumfacing$axis;
}
}
项目:nifi-swagger-client
文件:JSON.java
/**
* Deserialize
*
* @param json Json element
* @param date Type
* @param context Json Serialization Context
* @return Date
* @throws JsonParseException if fail to parse
*/
@Override
public Date deserialize(JsonElement json, Type date, JsonDeserializationContext context) throws JsonParseException {
String str = json.getAsJsonPrimitive().getAsString();
try {
return apiClient.parseDateOrDatetime(str);
} catch (RuntimeException e) {
throw new JsonParseException(e);
}
}
项目:gplaymusic
文件:AutogenEnumDeserializer.java
@Override
public ArtRef.Autogen deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (json.getAsBoolean()) {
return ArtRef.Autogen.TRUE;
}
return ArtRef.Autogen.FALSE;
}
项目:iosched-reader
文件:VendorDynamicInput.java
private void checkPagingConsistency(InputJsonKeys.VendorAPISource.MainTypes entityType,
int requestedPage, JsonObject obj) {
if (!obj.has("page") || !obj.has("pagesize") || !obj.has("total") ||
(!obj.has("results") && !obj.has("topics"))) {
throw new JsonParseException("Invalid response from Vendor API when"
+ "paging "+entityType+" results. At least one of the required properties "
+ "(page, pagesize, total, results|topics) could not be found.");
}
int currentPage = obj.get("page").getAsInt();
if (requestedPage>0 && requestedPage != currentPage) {
throw new JsonParseException("Invalid response from Vendor API when"
+ "paging "+entityType+" results. Requested page "+requestedPage
+" but got page "+currentPage);
}
}
项目:VISNode
文件:NodeNetworkParser.java
@Override
public T deserialize(JsonElement elem, Type interfaceType, JsonDeserializationContext context) throws JsonParseException {
final JsonObject wrapper = (JsonObject) elem;
final JsonElement typeName = get(wrapper, "type");
final JsonElement data = get(wrapper, "data");
final Type actualType = typeForName(typeName);
return createBareGsonBuilder().create().fromJson(data, actualType);
}
项目:Backmemed
文件:PlayerItemParser.java
private static void checkNull(Object p_checkNull_0_, String p_checkNull_1_)
{
if (p_checkNull_0_ == null)
{
throw new JsonParseException(p_checkNull_1_);
}
}
项目:BaseClient
文件:BlockFaceUV.java
private float[] parseUV(JsonObject p_178292_1_)
{
if (!p_178292_1_.has("uv"))
{
return null;
}
else
{
JsonArray jsonarray = JsonUtils.getJsonArray(p_178292_1_, "uv");
if (jsonarray.size() != 4)
{
throw new JsonParseException("Expected 4 uv values, found: " + jsonarray.size());
}
else
{
float[] afloat = new float[4];
for (int i = 0; i < afloat.length; ++i)
{
afloat[i] = JsonUtils.getFloat(jsonarray.get(i), "uv[" + i + "]");
}
return afloat;
}
}
}
项目:buckaroo
文件:Serializers.java
private static <T> Either<JsonParseException, T> parse(final String x, final Class<T> clazz) {
Preconditions.checkNotNull(x);
Preconditions.checkNotNull(clazz);
try {
final T t = gson.fromJson(
new EmptyStringFailFastJsonReader(new StringReader(x)), clazz);
return Either.right(t);
} catch (final JsonParseException e) {
return Either.left(e);
}
}
项目:Regalia
文件:RealmListGsonConverter.java
@Override
public RealmList<T> deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
RealmList<T> items = new RealmList<>();
JsonArray ja = json.getAsJsonArray();
for (JsonElement je : ja) {
items.add((T) context.deserialize(je, getObjectType()));
}
return items;
}
项目:Backmemed
文件:ItemTransformVec3f.java
public ItemTransformVec3f deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, 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(vector3f1.x, -5.0F, 5.0F);
vector3f1.y = MathHelper.clamp(vector3f1.y, -5.0F, 5.0F);
vector3f1.z = MathHelper.clamp(vector3f1.z, -5.0F, 5.0F);
Vector3f vector3f2 = this.parseVector3f(jsonobject, "scale", SCALE_DEFAULT);
vector3f2.x = MathHelper.clamp(vector3f2.x, -4.0F, 4.0F);
vector3f2.y = MathHelper.clamp(vector3f2.y, -4.0F, 4.0F);
vector3f2.z = MathHelper.clamp(vector3f2.z, -4.0F, 4.0F);
return new ItemTransformVec3f(vector3f, vector3f1, vector3f2);
}
项目:BaseClient
文件:PlayerItemParser.java
private static void checkNull(Object p_checkNull_0_, String p_checkNull_1_)
{
if (p_checkNull_0_ == null)
{
throw new JsonParseException(p_checkNull_1_);
}
}
项目:DecompiledMinecraft
文件:ItemCameraTransforms.java
public ItemCameraTransforms deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
ItemTransformVec3f itemtransformvec3f = this.func_181683_a(p_deserialize_3_, jsonobject, "thirdperson");
ItemTransformVec3f itemtransformvec3f1 = this.func_181683_a(p_deserialize_3_, jsonobject, "firstperson");
ItemTransformVec3f itemtransformvec3f2 = this.func_181683_a(p_deserialize_3_, jsonobject, "head");
ItemTransformVec3f itemtransformvec3f3 = this.func_181683_a(p_deserialize_3_, jsonobject, "gui");
ItemTransformVec3f itemtransformvec3f4 = this.func_181683_a(p_deserialize_3_, jsonobject, "ground");
ItemTransformVec3f itemtransformvec3f5 = this.func_181683_a(p_deserialize_3_, jsonobject, "fixed");
return new ItemCameraTransforms(itemtransformvec3f, itemtransformvec3f1, itemtransformvec3f2, itemtransformvec3f3, itemtransformvec3f4, itemtransformvec3f5);
}
项目:arquillian-reporter
文件:ReportJsonDeserializer.java
@Override
public Report deserialize(JsonElement json, Type typeOfReport, JsonDeserializationContext context)
throws JsonParseException {
JsonObject jsonReport = (JsonObject) json;
if (jsonReport.get("testSuiteReports") != null) {
return parseExecutionReport(jsonReport, context);
} else if (jsonReport.get("testClassReports") != null) {
return parseTestSuiteReport(jsonReport);
} else if (jsonReport.get("testMethodReports") != null) {
return parseTestClassReport(jsonReport);
} else if (jsonReport.get("startTime") != null) {
return parseTestMethodReport(jsonReport);
} else {
Report report;
if (typeOfReport.getTypeName().equals(ConfigurationReport.class.getTypeName())){
report = new ConfigurationReport();
} else if (typeOfReport.getTypeName().equals(FailureReport.class.getTypeName())){
report = new FailureReport();
} else {
report = new BasicReport();
}
return setDefaultValues(report, jsonReport);
}
}
项目:Backmemed
文件:BlockPart.java
private Map<EnumFacing, BlockPartFace> parseFacesCheck(JsonDeserializationContext deserializationContext, JsonObject object)
{
Map<EnumFacing, BlockPartFace> map = this.parseFaces(deserializationContext, object);
if (map.isEmpty())
{
throw new JsonParseException("Expected between 1 and 6 unique faces, got 0");
}
else
{
return map;
}
}
项目:CustomWorldGen
文件:BlockPart.java
private Map<EnumFacing, BlockPartFace> parseFacesCheck(JsonDeserializationContext deserializationContext, JsonObject object)
{
Map<EnumFacing, BlockPartFace> map = this.parseFaces(deserializationContext, object);
if (map.isEmpty())
{
throw new JsonParseException("Expected between 1 and 6 unique faces, got 0");
}
else
{
return map;
}
}
项目:Uranium
文件:TranslatableComponentSerializer.java
@Override
public TranslatableComponent deserialize(JsonElement json, Type typeOfT, 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, Type typeOfT, 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());
}
}
项目:rapid-io-android
文件:RapidGsonConverter.java
@Override
public synchronized Date deserialize(@NonNull JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
try {
return dateFormat.parse(jsonElement.getAsString());
} catch(ParseException e) {
throw new JsonParseException(e);
}
}
项目:CustomWorldGen
文件:LootPool.java
public LootPool deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot pool");
String name = net.minecraftforge.common.ForgeHooks.readPoolName(jsonobject);
LootEntry[] alootentry = (LootEntry[])JsonUtils.deserializeClass(jsonobject, "entries", p_deserialize_3_, LootEntry[].class);
LootCondition[] alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", new LootCondition[0], p_deserialize_3_, LootCondition[].class);
RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "rolls", p_deserialize_3_, RandomValueRange.class);
RandomValueRange randomvaluerange1 = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "bonus_rolls", new RandomValueRange(0.0F, 0.0F), p_deserialize_3_, RandomValueRange.class);
return new LootPool(alootentry, alootcondition, randomvaluerange, randomvaluerange1, name);
}
项目:MVVMFrames
文件:GsonResponseDeserializer.java
@Override
public ResponseEntity deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject response = json.getAsJsonObject();
if (response.get("result").isJsonPrimitive()) {// 是否为基本数据类型
int code = response.get("code").getAsInt();
String message = response.get("info").getAsString();
return new ResponseEntity(code, message);
}
return new Gson().fromJson(json, typeOfT);
}
项目:Readhub-Android
文件:EntityUtils.java
@Override
public OffsetDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String src = json.getAsString();
// TODO 有些时间结构不符合标准,这里做兼容
try {
return OffsetDateTime.parse(src);
} catch (DateTimeParseException e) {
return OffsetDateTime.of(LocalDateTime.parse(src, formatterCompat), ZoneOffset.UTC);
}
}
项目:Backmemed
文件:PlayerProfileCache.java
/**
* Load the cached profiles from disk
*/
public void load()
{
BufferedReader bufferedreader = null;
try
{
bufferedreader = Files.newReader(this.usercacheFile, Charsets.UTF_8);
List<PlayerProfileCache.ProfileEntry> list = (List)this.gson.fromJson((Reader)bufferedreader, TYPE);
this.usernameToProfileEntryMap.clear();
this.uuidToProfileEntryMap.clear();
this.gameProfiles.clear();
if (list != null)
{
for (PlayerProfileCache.ProfileEntry playerprofilecache$profileentry : Lists.reverse(list))
{
if (playerprofilecache$profileentry != null)
{
this.addEntry(playerprofilecache$profileentry.getGameProfile(), playerprofilecache$profileentry.getExpirationDate());
}
}
}
}
catch (FileNotFoundException var9)
{
;
}
catch (JsonParseException var10)
{
;
}
finally
{
IOUtils.closeQuietly((Reader)bufferedreader);
}
}