java - YAML Beans reading nested objects -
i have yaml file in format:
mongodb: - server: - host: localhost:27017 - minoploghours: 100 - maxsecondarydelay: 120 - server: - host: localhost:27018 - minoploghours: 100 - maxsecondarydelay: 120 - server: - host: localhost:27019 - minoploghours: 100 - maxsecondarydelay: 120 i need able access data each of host: fields each server: how can achieve this?
so far have this:
yamlreader reader = new yamlreader(new filereader("src/mongodb.yml")); object object = reader.read(); map resultmap = (map) object; system.out.println(resultmap.get("mongodb")); which prints:
[{server=[{host=localhost:27017}, {minoploghours=100}, {maxsecondarydelay=120}]}, {server=[{host=localhost:27018}, {minoploghours=100}, {maxsecondarydelay=120}]}, {server=[{host=localhost:27019}, {minoploghours=100}, {maxsecondarydelay=120}]}] how can extract server details string? more how can host: values.
i know old post don't see response. here think work you.
replace
map resultmap = (map) object; with
map<string, map<string, map<string, string>>> resultmap = (map<string, map<string, map<string, string>>>) object; i have had , worked. hope might someone.
Comments
Post a Comment