title: Reading data from json file for data provider in testng
body: <p>I want to provide data in my dataProvider using json file. Please suggest the best approach for it, (in java.)</p>
  
  <p>eg. Json file</p>
  
  <pre><code>{
    "dataSet": [
      {
        "testCase": "Verify error message on wrong userName",
        "username": "test",
        "password": "password",
        "rememberMe": false
      },
      {
        "testCase": "Verify error message on empty userName",
        "username": "",
        "password": "password",
        "rememberMe": false
      }
    ]
  }
  </code></pre>
  
  <p>And data provider should ideally look like</p>
  
  <pre><code>@DataProvider(name = "dpForIncorrectUsernameOrPassword")
  public static Object[][] incorrectUsernameOrPassword() {
      Object[][] testObjArray = JsonUtils.getJsonObjects("test.json");
      return testObjArray;
  }
  </code></pre>
  
  <p>So that </p>
  
  <pre><code>{
    "testCase": "Verify error message on wrong userName",
    "username": "test",
    "password": "password",
    "rememberMe": false
  }
  </code></pre>
  
  <p>this acts one data set, and </p>
  
  <pre><code>{
    "testCase": "Verify error message on empty userName",
    "username": "",
    "password": "password",
    "rememberMe": false
  }
  </code></pre>
  
  <p>acts another, and so on.. </p>