java - 表示我的 yaml 文件的更好方法是什么

标签 java yaml

是否有更好的方法来表示下面的 yaml 文件,以便更容易阅读和使用?目前我需要为每个创建 bean,我想知道是否有更好的方法来表示我的 yaml 文件,这样我就不需要这么庞大的结构

product:
  productId:
    instructions:
    exclude: false
    exists: true
    equals: false
    isSimple: true
  alternateId:
    instructions:
      exclude: true
      exists: false
      equals: false
      isSimple: true

productTotalPrice:
  priceType:
    exclude: false
    exists: true
    equals: true
    isSimple: true
  recurringChargePeriod:
    exclude: false
    exists: true
    equals: true
    isSimple: true
  taxRate:
    exclude: false
    exists: true
    equals: true
    isSimple: true
  price:
    exclude: false
    exists: true
    equals: true
    isSimple: false
  standalonePrice:
    exclude: false
    exists: true
    equals: true
    isSimple: false
  finalPrice:
    exclude: false
    exists: true
    equals: true
    isSimple: false


standalonePrice:
  taxIncludedAmount:
    exclude: false
    exists: true
    equals: true
    isSimple: false
  dutyFreeAmount:
    exclude: false
    exists: true
    equals: true
    isSimple: false

最佳答案

我建议使用:

public static JsonNode myMap;

myMap = mapper.readTree(new File("....yaml"));

关于java - 表示我的 yaml 文件的更好方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54389020/

相关文章:

java - 如何通过 FileReader 解决异常

java - 使用@Before 和 xml 文件在 Hibernate 和 MySQL 中设置默认日期

java - 使用 SnakeYAML 编写 YAML 文件

python - Pyyaml 转储不会为相同对象生成 anchor

java - Java 有 IndexSet 和 Range 类吗?

java - Android-由于 java.lang.NullPointerException 无法显示收到的位置值

yaml - 开放API继承示例数据

json - 比SQLite更简单

php - 用 PHP 读取 Yaml

java - 如何使 java 类可序列化并扩展不可序列化的类