Как и при разборе JSON, вы можете разобрать в Map
:
Пример
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
@SuppressWarnings("unchecked")
Map<String, Object> map = mapper.readValue(new File("test.yaml"), Map.class);
System.out.println(map);
test.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
Выход
{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}]}