InterviewSolution
Saved Bookmarks
| 1. |
How to use YAML files in high programming languages such as JAVA, Python, etc? |
|
Answer» YAML is supported in most programming languages and can be easily integrated with USER programs. Similarly, we can read from YAML also: // Loading the YAML file from the /resources folderClassLoader classLoader = Thread.currentThread().getContextClassLoader();File file = new File(classLoader.getResource("topic.yaml").getFile());// Instantiating a new ObjectMapper as a YAMLFactoryObjectMapper om = new ObjectMapper(new YAMLFactory());// Mapping the employee from the YAML file to the Employee classTopic topic = om.readValue(file, Topic.class);In python similarly, we can use the pyyaml library and read and write easily in YAML format. |
|