我有以下YAML文件:
customers:
UniqueProductName1:
SubscriptionPlan1:
User1: {payment:150, limit: 200}
User2: {payment:200, limit: 300}
User3: {payment:60, limit: 100}
SubscriptionPlan2:
User1: {payment:150, limit: 200}
User2: {payment:200, limit: 300}
User5: {payment:150, limit: 200}
UniqueProductName2:
SubscriptionPlan1:
User6: {payment:150, limit: 200}
User7: {payment:200, limit: 300}
User4: {payment:60, limit: 100}
SubscriptionPlan2:
User5: {payment:150, limit: 200}
User8: {payment:200, limit: 300}
User9: {payment:150, limit: 200}
SubscriptionPlan3:
User5: {payment:150, limit: 200}
User8: {payment:200, limit: 300}
User10: {payment:150, limit: 200}
如何获得UniqueProductName1.SubscriptionPlan1.User3.payment
的值?
在此yaml文件内容中没有描述UniqueProductName1是“产品”等内容的字段
我尝试使用杰克逊jar:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.8.3</version>
</dependency>
我创建了以下Java bean:
MainYaml.java:
@Configuration
@EnableConfigurationProperties
@ConfigurationProperties("customers")
public class MainYaml {
public List<CustomerProduct> customerProductList;
//getter and setter
CustomerProduct.java :(我是否也需要在这里使用@configurationproperties注释?)
public class CustomerProduct{
public String productName;
public List<CustomerPlan> customerPlansList;
//getter and setter
CustomerPlan.java:
public class CustomerPlan{
public String planName;
public List<Customer> customerList;
//getter and setter
Customer.java:
@Component
public class Customer{
public String customerName;
public CustomerDetail customerDetail ;
//getter and setter
CustomerDetail.java:
public class CustomerDetail {
@JsonProperty
public String payment;
@JsonProperty
public String limit;
由于