Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I deseralize json object in java pojo class?
    text
    copied!<p>I have a simple JSON statement which type is very per need. like this </p> <pre><code> { actor:{name:"kumar",mbox:"kumar@gmail.com"} verb :"completed" } </code></pre> <p>or</p> <pre><code>{ actor:{name:["kumar","manish"],mbox:["kumar@gmail.com","manish@gmail.com"]} verb :{ "id" : "http://adlnet.gov/expapi/verbs/completed", "display" : { "en-US" : "completed" } } </code></pre> <p>I am using using POJO class to map this json string and pojo class code is given bleow</p> <pre><code>@JsonProperty("actor") Actor actor; @JsonProperty("verb") Verb objVerb; @JsonProperty("verb") String verb; public Actor getActor() { return actor; } public void setActor(Actor actor) { this.actor = actor; } public Verb getObjVerb() { return objVerb; } public void setObjVerb(Verb objVerb) { this.objVerb = objVerb; } @JsonIgnore public String getVerb() { return verb; } @JsonIgnore public void setVerb(String verb) { this.verb = verb; } public static class Actor { String objectType; @JsonProperty("name") ArrayList&lt;String&gt; listName; @JsonProperty("name") String name; @JsonProperty("mbox") ArrayList&lt;String&gt; listMbox; @JsonProperty("mbox") String mbox; @JsonProperty("mbox_sha1sum") ArrayList&lt;String&gt; Listmbox_sha1sum; @JsonProperty("mbox_sha1sum") String mbox_sha1sum; @JsonProperty("openid") String openid; @JsonProperty("account") Account account; public String getObjectType() { return objectType; } public void setObjectType(String objectType) { this.objectType = objectType; } public ArrayList&lt;String&gt; getListName() { return listName; } public void setListName(ArrayList&lt;String&gt; listName) { this.listName = listName; } @JsonIgnore public String getName() { return name; } @JsonIgnore public void setName(String name) { this.name = name; } public ArrayList&lt;String&gt; getListMbox() { return listMbox; } public void setListMbox(ArrayList&lt;String&gt; listMbox) { this.listMbox = listMbox; } @JsonIgnore public String getMbox() { return mbox; } @JsonIgnore public void setMbox(String mbox) { this.mbox = mbox; } public ArrayList&lt;String&gt; getListmbox_sha1sum() { return Listmbox_sha1sum; } public void setListmbox_sha1sum(ArrayList&lt;String&gt; listmbox_sha1sum) { Listmbox_sha1sum = listmbox_sha1sum; } @JsonIgnore public String getMbox_sha1sum() { return mbox_sha1sum; } @JsonIgnore public void setMbox_sha1sum(String mbox_sha1sum) { this.mbox_sha1sum = mbox_sha1sum; } public String getOpenid() { return openid; } public void setOpenid(String openid) { this.openid = openid; } public Account getAccount() { return account; } public void setAccount(Account account) { this.account = account; } public static class Account { @JsonProperty("homePage") String homePage; @JsonProperty("name") String name; public String getHomePage() { return homePage; } public void setHomePage(String homePage) { this.homePage = homePage; } public String getName() { return name; } public void setName(String name) { this.name = name; } } } public static class Verb { String id; Map&lt;String,String&gt; display; public String getId() { return id; } public void setId(String id) { this.id = id; } public Map&lt;String, String&gt; getDisplay() { return display; } public void setDisplay(Map&lt;String, String&gt; display) { this.display = display; } } </code></pre> <p>I am using jaxb and jakson. I am implementing the webservice to handle the json statement so I use the bean class to map with json. But when I use to map this json then it gives the following exceptions </p> <blockquote> <p>org.codehaus.jackson.map.JsonMappingException : property with the name "mbox" have two entry.</p> </blockquote> <p>Define a proper bean structure so it directly mapped to the beans class</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload