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 <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); } }