New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixin Issue #1380
Comments
As per exception, you may disable the features ( But it depends: would you want to get some properties serialized, or is empty Object fine? |
Is there any way (With the help of mixing or some other way), can I serilize/deserialize User object with out modifying(i.e. Adding getter/setter) it |
@mnadeem asking same question again without more information is not going to get you an answer.
So what is your remaining problem? |
Well my problem (As I stated earlier) is I have got 3rd party library, and for some reason those have to be marshalled/marshalled into json, and I cannot provided getters only for the sake of marshalling/unmarshalling. I was expecting the framework to be smart enough (Use reflection, what not). If the framework cannot provide such basic thing, that means, (as I understand) is not the write one for the use case (And I have to escalate it, not to be used any further) Well I don't have to go any further (I got the answer), I understand, why the framework is like this, partly because people like @cowtowncoder is maintaining it, smart enough in giving childish answer Dude, I read that, I have seen it, and that is the reason I have made that one, to appear in bold, not sure if you have seen it. I feel there should be a guide line to respond to issues as well. |
@mnadeem You do not make any sense whatever. So your not asking any more questions without adequate information is a big win for me. Feel free to use some other library and pester its maintainers. |
For those of you interested in solution (and don't care about use case), use the following code, and things would work like a charm
Above code wont force you to have public getter of private field. |
@mnadeem thank you for sharing the solution for anyone else looking. For sake of completeness, there is also |
I have documented about this in this blog |
User Class
Corresponding mixing
}
TEST class
}
If I run the class everything as expected
Removed the following two getters from User class
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class com.github.dexecutor.redisson.User and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:269)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:68)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:130)
at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3631)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:2998)
at com.github.dexecutor.redisson.JacksonMixIn.main(JacksonMixIn.java:14)
How do I marshal/un marshall objects in this case??
Note: I cant add the getter: it would be 3rd party class
The text was updated successfully, but these errors were encountered: