forked from anshulc55/JavaTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadYAMLData.java
More file actions
37 lines (23 loc) · 907 Bytes
/
ReadYAMLData.java
File metadata and controls
37 lines (23 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package utilities;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.List;
import java.util.Map;
import com.esotericsoftware.yamlbeans.YamlException;
import com.esotericsoftware.yamlbeans.YamlReader;
public class ReadYAMLData {
public static void main(String[] args) throws FileNotFoundException, YamlException {
String filepath = System.getProperty("user.dir") + "//testData.yml";
FileReader file = new FileReader(filepath);
YamlReader reader = new YamlReader(file);
//Map - JSONObject
//List - JSONArray
Map testData = (Map)reader.read();
List testCases = (List) testData.get("testdata");
System.out.println(testCases);
Map loginTestData = (Map) testCases.get(0);
System.out.println(loginTestData.get("testName"));
List loginTestDataData = (List) loginTestData.get("data");
System.out.println(loginTestDataData);
}
}