YAML is supported in most programming languages and can be easily integrated with user programs.
In JAVA we can use the Jackson module which also parses XML and JSON. For e.g
List<Topic> topics = new ArrayList<Topic>();
topics.add(new Topic("String Manipulation", 10, 6));
topics.add(new Topic("Knapsack", 5, 5));
topics.add(new Topic("Sorting", 20, 13));
Topic topic = new Topic("DS & Algo", 35, 24, topics);
ObjectMapper om = new ObjectMapper(new YAMLFactory());
om.writeValue(new File("/src/main/resources/topics.yaml"), topic);
---
name: "DS & Algo"
total_score: 35
user_score: 24
sub_topics:
- name: "String Manipulation"
total_score: 10
user_score: 6
- name: "Knapsack"
total_score: 5
user_score: 5
- name: "Sorting"
total_score: 20
user_score: 13
Similarly, we can read from YAML also:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
File file = new File(classLoader.getResource("topic.yaml").getFile());
ObjectMapper om = new ObjectMapper(new YAMLFactory());
Topic topic = om.readValue(file, Topic.class);
In python similarly, we can use the pyyaml library and read and write easily in YAML format.