【发布时间】:2022-11-26 05:35:32
【问题描述】:
我目前有一个如下所示的 yaml 文件:
description: this-apps-config
options:
- customer: joe
id: 1
date: 2022-01-01
print: False
- customer: jane
id: 2
date: 2022-01-02
print: True
我能够使用 snakeyaml 成功阅读此内容:
Yaml yaml = new Yaml();
InputStream inputStream = new FileInputStream(new File("file.yml"));
Map<String, Object> data = yaml.load(inputStream);
System.out.println(data);
上面的代码将所有内容作为 LinkedHashMap 检索,options 是另一个 HashMap 的 ArrayList,如下所示:
{description=this-apps-config, options=[{customer=joe, id=1, date=2022-01-01, print=False}, {customer=jane, id=2, date=2022-01-02, print=True}]}
我的问题是,如何在每个options 中获取print 值?我得到的最接近的是:
ArrayList<Object> al = new ArrayList<>()
al.add(data.get("options"))
不过,这只会让我首先看到 options ArrayList。不确定如何更深入。
谢谢
【问题讨论】: