title: Convert JSON values into their appropriate data types
body: <p>I have some Json data and I need to return each value as a string or number or which data type it returns..
  But I am facing java.lang.ClassNotFoundException: Validation
      at java.net.URLClassLoader.findClass(Unknown Source)</p>
  
  <pre><code>  public class Validation {
          public void readJSON() throws Exception {
                  File file = new File("myJSONFile.txt");
                  String content = FileUtils.readFileToString(file, "utf-8");
  
                  // Convert JSON string to JSONObject
                  JSONObject tomJsonObject = new JSONObject(content);
                  System.out.println(tomJsonObject);
                  System.out.println(tomJsonObject.getString("age"));
                  validateByType(tomJsonObject, "age", null);
              }
  
              public void validateByType(JSONObject jsonString, String pathString, String typeString)
                      throws JSONException, ClassNotFoundException, NoSuchFieldException, SecurityException {
                  String jsonField = jsonString.getString(pathString);
                  // pathString = "age";
                  // typeString ="number";
  
                  Class&lt;?&gt; c = Class.forName("Validation");
                  Field f = c.getField(jsonField);
                  System.out.format("Type: %s%n", f.getType());
                  System.out.format("GenericType: %s%n", f.getGenericType());
  
              }
  
              public static void main(String[] args) {
                  // TODO Auto-generated method stub
                  System.out.println("Test");
                  Validation v = new Validation();
                  try {
                      v.readJSON();
  
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
  
          }
  </code></pre>