Created
July 29, 2020 07:42
-
-
Save sumitsahoo/1b61394500b94316fe870b51ba8e0e5f to your computer and use it in GitHub Desktop.
Check if a string is a valid JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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