Reputation: 11728
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.
Upvotes: 0
Views: 1668
Reputation:
Replace the second line with:
List<Map<String, Object>> data = (List<Map<String, Object>>) yaml.load(questionsStream);
The Object
s from inside the Map
can be cast to Maps
or Lists
and iterated through the same way, depending on the yaml file structure.
Upvotes: 1