Skip to content

Instantly share code, notes, and snippets.

@sumitsahoo
Created July 29, 2020 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumitsahoo/1b61394500b94316fe870b51ba8e0e5f to your computer and use it in GitHub Desktop.
Save sumitsahoo/1b61394500b94316fe870b51ba8e0e5f to your computer and use it in GitHub Desktop.
Check if a string is a valid JSON
private static boolean isJson(String Json) {
try {
new JSONObject(Json);
} catch (JSONException ex) {
try {
new JSONArray(Json);
} catch (JSONException ex1) {
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment