public static WrappedStack createFromJson(String jsonWrappedObject) throws JsonParseException { try { return gsonSerializer.fromJson(jsonWrappedObject, WrappedStack.class); } catch (JsonSyntaxException exception) { LogHelper.severe(exception.getMessage()); } catch (JsonParseException exception) { LogHelper.severe(exception.getMessage()); } return null; }
public static WrappedStack createFromJson(String jsonWrappedObject) throws JsonParseException { try { return jsonSerializer.fromJson(jsonWrappedObject, WrappedStack.class); } catch (JsonSyntaxException exception) { exception.printStackTrace(); } catch (JsonParseException exception) { exception.printStackTrace(); } return null; }
protected List<CardData> loadRawData() { try { return gson.fromJson(readLibrarySource(), getType()); } catch (JsonIOException e) { e.printStackTrace(); } catch (JsonSyntaxException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } return Collections.emptyList(); }
/** * Deserializes an EmcValue object from the given serialized json String * * @param jsonEnergyValue Json encoded String representing a EmcValue object * @return The EmcValue that was encoded as json, or null if a valid EmcValue could not be decoded * from given String */ @SuppressWarnings("unused") public static EnergyValue createFromJson(String jsonEnergyValue) { try { return jsonSerializer.fromJson(jsonEnergyValue, EnergyValue.class); } catch (JsonSyntaxException exception) { exception.printStackTrace(); } catch (JsonParseException exception) { exception.printStackTrace(); } return null; }
public static <R> R parseJson(okhttp3.Response response, Type bodyType) throws HasuraJsonException { int code = response.code(); try { String rawBody = response.body().string(); System.out.println(rawBody); return gson.fromJson(rawBody, bodyType); } catch (JsonSyntaxException e) { String msg = "FATAL : JSON strucutre not as expected. Schema changed maybe? : " + e.getMessage(); throw new HasuraJsonException(code, msg, e); } catch (JsonParseException e) { String msg = "FATAL : Server didn't return vaild JSON : " + e.getMessage(); throw new HasuraJsonException(code, msg, e); } catch (IOException e) { String msg = "FATAL : Decoding response body failed : " + e.getMessage(); throw new HasuraJsonException(code, msg, e); } }
@Override public Deck loadDeck(String name) { DeckData data; try { data = gson.fromJson(readSource(getDeckUri(name)), DeckData.class); CardLibrary cl = loadCardLibrary(); Card identityCard = cl.getCard(data.getIdentity()); Deck deck = new Deck(cl.getItentity(identityCard.getKey()), data.getName()); for (CardRef ref : data.getCards()) { deck.add(cl.getCard(ref.getCard()), ref.getCount()); } return deck; } catch (JsonIOException e) { e.printStackTrace(); } catch (JsonSyntaxException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; }