eugenp/tutorials

[ISSUE] Can not handle multi sections in yaml in "How to Process YAML with Jackson"

Closed this issue · 1 comments

Article and Module Links
https://www.baeldung.com/jackson-yaml

Describe the Issue

@Getter
@Setter
public class Order {
    private String env;
    private String orderNo;
    private LocalDate date;
    private String customerName;
    private List<OrderLine> orderLines;
}
@Getter
@Setter
public class OrderLine {
    private String item;
    private int quantity;
    private BigDecimal unitPrice;
}
profiles:
    active: dev
---
env: dev
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

---
env: test
orderNo: A002
date: 2019-04-16
customerName: Customer, Joe
orderLines:
    -   item: No. 9 Sprockets
        quantity: 12
        unitPrice: 1.23
    -   item: Widget (10mm)
        quantity: 4
        unitPrice: 3.45

Expected Behavior
I hope to show how to handle muti sections in yaml.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: windows
  • jdk: 1.8

Hi @liu1084,

Thanks for the feedback. Reading objects based on the profile in a single YAML file wouldn’t be possible in this case.

Cheers