I want to parse multiple yaml files and add a print them on a table. I have the code to parse the yaml, but I am trying to figure out a way to add a property to the class (if not available).
Below is my code
public void readyml() throws JsonParseException, JsonMappingException, IOException{
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.findAndRegisterModules();
Order order = mapper.readValue(new File("src/main/resources/orderInput.yaml"), Order.class);
System.out.println("order ::: " + order);
}
the above code reads src/main/resources/orderInput.yaml
orderNo: A001
date: 2019-04-17
customerName: Customer, Joe
orderLines:
- item: No. 9 Sprockets
quantity: 12
unitPrice: 1.23
- item: Widget (10mm)
quantity: 4
unitPrice: 3.45
maps them to the Order
and OrderList
classes, and prints the values
My problem is, incase there is a new property added to the yaml, I want my code to pick it up
Can you please help