java - Jackson Exception when parsing Yaml with a Map of List values -



java - Jackson Exception when parsing Yaml with a Map of List values -

i have yaml document includes map entries correspond lists. here's example:

environments: qa: [ 'us-east-1' ] staging: [ 'us-east-1', 'us-west-2' ]

i using jackson 2.3.2 parse document class using next field & accessors:

private map<string, list<string>> environments = new hashmap<string, list<string>>(); @jsonproperty public map<string, list<string>> getenvironments() { homecoming environments; } @jsonproperty public void setenvironments(map<string, list<string>> environments) { this.environments = environments; }

i'm testing reading of yaml file following:

inputstream = new fileinputstream("src/test/resources/configuration_test.yml"); config = mapper.readvalue(inputstream, myconfiguration.class);

the next exception thrown stacktrace that's not particularly helpful:

caused by: java.lang.illegalargumentexception: can not find deserializer non-concrete collection type [collection type; class com.google.common.collect.immutablelist, contains [simple type, class io.dropwizard.metrics.reporterfactory]] @ com.fasterxml.jackson.databind.deser.basicdeserializerfactory.createcollectiondeserializer(basicdeserializerfactory.java:814) @ com.fasterxml.jackson.databind.deser.deserializercache._createdeserializer2(deserializercache.java:392) @ com.fasterxml.jackson.databind.deser.deserializercache._createdeserializer(deserializercache.java:350) @ com.fasterxml.jackson.databind.deser.deserializercache._createandcache2(deserializercache.java:263) ... 42 more

any thought how jackson parse map value list?

you need configure objectmapper. in dropwizard, there jackson.newobjectmapper()

java jackson yaml dropwizard

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -