Код: Выделить всё
public static boolean isJson(String Json) {
Gson gson = new Gson();
try {
gson.fromJson(Json, Object.class);
return true;
} catch (com.google.gson.JsonSyntaxException ex) {
return false;
}
}
Код: Выделить всё
System.out.println(renderHtml.isJson("{\"status\": \"UP\"}"));
Код: Выделить всё
System.out.println(renderHtml.isJson("bncjbhjfjhj"));
Подробнее здесь: https://stackoverflow.com/questions/432 ... using-gson
Мобильная версия