private JsonArray testParseHelper(String objStr) { try { return new TestArray(objStr, false); } catch (JsonParseException e) { previousError = e.getMessage(); e.printStackTrace(); return null; } }
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; }
/** * 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; }
/** * Returns the next available {@link JsonElement} on the reader. Null if none available. * * @return the next available {@link JsonElement} on the reader. Null if none available. * @throws JsonParseException if the incoming stream is malformed JSON. * @since 1.4 */ public JsonElement next() throws JsonParseException { if (!hasNext()) { throw new NoSuchElementException(); } 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; } }
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); } }