Package com.massivecraft.mcore.xlib.gson

Examples of com.massivecraft.mcore.xlib.gson.JsonParseException


    }
   
    try {
      return Streams.parse(parser);
    } catch (StackOverflowError e) {
      throw new JsonParseException("Failed parsing JSON source to Json", e);
    } catch (OutOfMemoryError e) {
      throw new JsonParseException("Failed parsing JSON source to Json", e);
    } catch (JsonParseException e) {
      throw e.getCause() instanceof EOFException ? new NoSuchElementException() : e;
    }
  }
View Full Code Here


  }

  public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
      throws JsonParseException {
    if (!(json instanceof JsonPrimitive)) {
      throw new JsonParseException("The date should be a string value");
    }
    Date date = deserializeToDate(json);
    if (typeOfT == Date.class) {
      return date;
    } else if (typeOfT == Timestamp.class) {
View Full Code Here

    boolean lenient = json.isLenient();
    json.setLenient(true);
    try {
      return Streams.parse(json);
    } catch (StackOverflowError e) {
      throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e);
    } catch (OutOfMemoryError e) {
      throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e);
    } catch (JsonParseException e) {
      if (e.getCause() instanceof EOFException) {
        return JsonNull.INSTANCE;
      }
      throw e;
View Full Code Here

  @Override
  public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
  {
    if (!json.isJsonObject())
    {
      throw new JsonParseException("A polymorph must be an object.");
    }
   
    JsonObject jsonObject = json.getAsJsonObject();
   
    if (!jsonObject.has(TYPE))
    {
      throw new JsonParseException("A polymorph must be have a \""+TYPE+"\" field.");
    }
   
    if (!jsonObject.has(VALUE))
    {
      throw new JsonParseException("A polymorph must be have a \"+VALUE+\" field.");
    }
   
    String type = ((JsonPrimitive)jsonObject.get(TYPE)).getAsString();
   
    Class<?> typeClass = null;
    try
    {
      typeClass = Class.forName(type);
    }
    catch (ClassNotFoundException e)
    {
      e.printStackTrace();
      throw new JsonParseException(e.getMessage());
    }
    return context.deserialize(jsonObject.get(VALUE), typeClass);
  }
View Full Code Here

TOP

Related Classes of com.massivecraft.mcore.xlib.gson.JsonParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.