java - Json ObjectMapper unable to read Json value -
i have enum class
public enum cachetype { none("none"), nonstrict_read_write("nonrestrictreadwrite"), read_only("readonly"), read_write("readwrite"); private final string text; private cachetype(final string text) { this.text = text; } @jsonvalue public string gettext() { return text; } }
now have table class
public class table { private cachetype cachetype; .... getters , setters }
now if json sent spring controller table
constructed cachetype
set. till okay.
now doing unit test
read json test file follows , convert object:
import com.fasterxml.jackson.databind.objectmapper; private final objectmapper mapper = new objectmapper(); table= mapper.readvalue(file, table.class);
here cachetype
set null
. rest of table attributes set properly. how can read cachetype
properly
{ "tables":[ { "name": "dummyusers", "namespace": "", "cachetype": "readwrite" }, { "name": "adminusers", "namespace": "", "cachetype": "nonrestrictreadwrite" }, { "name": "superusers", "namespace": "", "cachetype": "none" } ] }
Comments
Post a Comment