GeneralUtils { public static boolean isJsonStart(String raw) { int size = raw.length(); int index = 0; while (index < size) { char ch = raw.charAt(index); if (ch != ' ') { switch (ch) { case '"': case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '[': case '{': return true; case 'f': return raw.startsWith("false"); case 'n': return raw.startsWith("null"); case 't': return raw.startsWith("true"); default: return false; } } index++; } return false; } private  GeneralUtils(); static long toPositiveLong(CharSequence seq, int pos, int length); static Decimal nodeToDecimal(JsonNode node); static BigDecimal nodeToBigDecimal(JsonNode node); static JsonNode executeTemplate(Context ctx, Instruction inst, JsonNode node, boolean privateContext); static JsonNode executeTemplate(Context ctx, Instruction inst, JsonNode node, boolean privateContext,
        ObjectNode argvar); static String loadResource(Class<?> cls, String path); static List<Path> listResources(Class<?> cls, String pattern); static V getOrDefault(Map<K, V> map, K key, V defaultValue); static String localizeOrDefault(JsonNode localizedStrings, String key, String defaultValue); static boolean isJsonStart(String raw); static JsonNode getFirstMatchingNode(JsonNode parent, String... keys); static String jsonPretty(JsonNode node); static Object[] splitVariable(String name); static String urlEncode(String val); static boolean isTruthy(JsonNode node); static String ifString(JsonNode node, String defaultString); static double ifDouble(JsonNode node, double defaultValue); static String eatNull(JsonNode node);  }
@Test public void testIsJsonStart() { assertTrue(isJsonStart("123")); assertTrue(isJsonStart(" 123")); assertTrue(isJsonStart(" {\"key\": \"val\"}")); assertTrue(isJsonStart(" [1, 2, 3]")); assertFalse(isJsonStart(":123")); assertFalse(isJsonStart("'foo'")); assertFalse(isJsonStart(" ")); }