- //validation for numeric
- protected boolean isNumeric(String str){
- for (char c : str.toCharArray()){
- if (!Character.isDigit(c)) return false;
- }
- return true;
- }
-
- // Validation for json.
- protected static boolean isJSONValid(String data) {
- JsonReader jsonReader = null;
- try {
- new JSONObject(data);
- InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
- jsonReader = Json.createReader(stream);
- LOGGER.info("Json Value is: " + jsonReader.read().toString() );
- } catch (Exception e) {
- LOGGER.error("Exception Occured while reading json"+e);
- return false;
- }finally{
- if(jsonReader != null){
- jsonReader.close();
- }
- }
- return true;
- }
-