@Test public void isJsonObject() { assertThat(JsonUtils.isJsonObject(null)).isFalse(); assertThat(JsonUtils.isJsonObject("")).isFalse(); assertThat(JsonUtils.isJsonObject("{}")).isTrue(); assertThat(JsonUtils.isJsonObject("{\"foo\": \"bar\"}")).isTrue(); assertThat(JsonUtils.isJsonObject(" {\"foo\": \"bar\"} ")).isTrue(); assertThat(JsonUtils.isJsonObject("\n{\"foo\": \"bar\"}\n")).isTrue(); assertThat(JsonUtils.isJsonObject("[]")).isFalse(); }
public static boolean isJsonObject(String value) { if (Strings.isEmptyOrBlank(value)) { return false; } final String trimmed = value.trim(); return trimmed.charAt(0) == '{' && trimmed.charAt(trimmed.length() - 1) == '}'; }
JsonUtils { public static boolean isJsonObject(String value) { if (Strings.isEmptyOrBlank(value)) { return false; } final String trimmed = value.trim(); return trimmed.charAt(0) == '{' && trimmed.charAt(trimmed.length() - 1) == '}'; } }
JsonUtils { public static boolean isJsonObject(String value) { if (Strings.isEmptyOrBlank(value)) { return false; } final String trimmed = value.trim(); return trimmed.charAt(0) == '{' && trimmed.charAt(trimmed.length() - 1) == '}'; } private  JsonUtils(); }
JsonUtils { public static boolean isJsonObject(String value) { if (Strings.isEmptyOrBlank(value)) { return false; } final String trimmed = value.trim(); return trimmed.charAt(0) == '{' && trimmed.charAt(trimmed.length() - 1) == '}'; } private  JsonUtils(); static ObjectReader reader(); static T readFromStream(final InputStream stream, final Class<T> type); static ObjectWriter writer(); static ObjectMapper copyObjectMapperConfiguration(); static Map<String, Object> map(Object... values); static T convertValue(final Object fromValue, final Class<T> toValueType); static boolean isJson(String value); static boolean isJsonObject(String value); static boolean isJsonArray(String value); static List<String> arrayToJsonBeans(JsonNode json); static String jsonBeansToArray(List<?> jsonBeans); static String toPrettyString(Object value); static String toString(Object value); }
JsonUtils { public static boolean isJsonObject(String value) { if (Strings.isEmptyOrBlank(value)) { return false; } final String trimmed = value.trim(); return trimmed.charAt(0) == '{' && trimmed.charAt(trimmed.length() - 1) == '}'; } private  JsonUtils(); static ObjectReader reader(); static T readFromStream(final InputStream stream, final Class<T> type); static ObjectWriter writer(); static ObjectMapper copyObjectMapperConfiguration(); static Map<String, Object> map(Object... values); static T convertValue(final Object fromValue, final Class<T> toValueType); static boolean isJson(String value); static boolean isJsonObject(String value); static boolean isJsonArray(String value); static List<String> arrayToJsonBeans(JsonNode json); static String jsonBeansToArray(List<?> jsonBeans); static String toPrettyString(Object value); static String toString(Object value);  }