Saturday, 15 February 2014

java - Unrecognized field "User" (Class com.test.webservice.bean.User), not marked as ignorable -


Hello, I'm trying to change the Jason object below by jersey service,

 < "Test", "address": "test", "address": "new name", "password": "new password", "email": "test.test@test.com", "address" I get the following example: "test", "last name": "test", "city": "test"}}  

I get the following error:

  Unrecognized area "user" (class com.test.webservice.bean.User), [source: io.undertow.servlet.spec.ServletInputStre AmImpl @ 1d89c0 is not marked as arrogant; Line: 11, column: 2] (Through the reference series: com.test.webservice.bean.User ["user"])  

In addition, if I @ JSONIgnoreProperties to TRUE , The full user object is ignored and I get zero values ​​for all the fields.

I am also aware of Object Mapper which I have set below:

  Private static ObjectMapper createCustomObjectMapper () {New Object Mapper (.) .configure (SerializationFeature. WRAP_ROOT_VALUE, true). Configure (DeserializationFeature.UNWRAP_ROOT_VALUE, true). Configure (DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, incorrect) .setAnnotationIntrospector (createJaxbJacksonAnnotationIntrospector ()); }  

I am using Jackson 2.0, the sample code for User Bean is as follows

  ** Package Com Test.webserver Bean; Import javax.preistence *; Import org.codehaus.jackson.annotate.JsonCreator; Import org.codehaus.jackson.annotate.JsonProperty; @ Entity @Table (name = "user") public class user {@JsonCreator public user (@Jesonsproperty ("username") string user name, @Jesonproperty ("password") string password, jasonproperty ("email") string email , @Jasonproporty ("first name") string firstname, @JespronProperty ("last name") string lastname, @JespronProperty ("address") string address, @Jesproforty ("city" str Yang City) {this.username = Username; This.password = Password; This.email = email; This.FirstName = FirstName; This.LastName = LastName; This address = address; this city = city;} **  

And if I set the json object below it works fine

  {"username": "newusername", "password": " New test word "test", "test.test@adrosonic.com", "address": "test", "firstname": "test", "lastname": "test", "city": "test"} < / Code> 

I want to know how this should work like this, or if there is any alternative solution in this situation, leaving the json string.

Thank you for your time


No comments:

Post a Comment