SnakeYAML JAVA:使用生成的对象
我正在尝试使用 SnakeYAML 将 YAML 文件加载到 Android Java 类中的对象中。如何访问结果对象的成员?
Yaml yaml = new Yaml();
Object data = yaml.load(questionsStream);
Log.v(TAG2,data.toString());
输出为:
03-07 18:15:55.637: VERBOSE/Q_Engine 负载问题(615): [{Answer=Sun Jun 25 01:00:00 GMT+01:00 1950, ID=8, Meta Info={Main Topics=[朝鲜战争]}、Obscurity=1、Question=朝鲜战争何时开始?}等...
我想遍历地图列表并通过关键字访问其成员。
I am attempting to use snakeYAML to load a YAML file into an object in an Android Java Class. How do I access the members of the resulting object?
Yaml yaml = new Yaml();
Object data = yaml.load(questionsStream);
Log.v(TAG2,data.toString());
The output is:
03-07 18:15:55.637: VERBOSE/Q_Engine Load Questions(615): [{Answer=Sun Jun 25 01:00:00 GMT+01:00 1950, ID=8, Meta Info={Main Topics=[Korean War]}, Obscurity=1, Question=When did the Korean War begin?}, etc...
I want to iterate through the list of Maps and access their members by their keywords.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将第二行替换为:
Map
内部的Object
可以转换为Maps
或Lists
并进行迭代通过同样的方式,取决于yaml文件结构。Replace the second line with:
The
Object
s from inside theMap
can be cast toMaps
orLists
and iterated through the same way, depending on the yaml file structure.将您的数据投射到地图列表并进行迭代。
Cast your data to list of Maps and iterate.