2728293031323334353637
private static final String WHILE_1 = "while(1);"; public static boolean isValidJson(String value) { try { JSON json = new JsonSlurper().parseText(value); return json != null && !(json instanceof JSONNull); } catch (Exception e) { return false; } }
5051525354555657585960
public static boolean seemsToBeJson(String content) { if (!StringUtils.hasContent(content)) { return false; } try { new JsonSlurper().parseText(content); return true; } catch (Exception e) { return false; } }
36373839404142
public JsonPathFacade(String targetJson) { if (!isValidJson(targetJson)) { throw new IllegalArgumentException("Invalid JSON: " + targetJson); } this.currentJson = targetJson; jsonObject = new JsonSlurper().parseText(targetJson); }