-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow "Serialize as POJO" using @JsonFormat(shape=Shape.OBJECT)
class annotation
#476
Comments
No reason beyond bug or omission. I think blog entry is incorrect here; since But perhaps you are thinking more about "serialize as POJO" for Maps? I am not sure what'd be suitable override there. |
yes, "serialize as POJO" was my understanging of |
It's not that "serialize as POJO" is not doable (it is); it's more that use of So, it'd be necessary to know proper way to indicate such variant. |
ok, I see your point, although I think it's not an incostitency since the result is still Json Object if we use POJO serializer either, but I agree that there would be some ambiguity. |
+1 |
I don't think anyone is working on this at this point. Now, similar to my comment on an issue related to |
FWIW, #865 is the related issue. |
This is implementable at this point, considering there's The reverse side of accepting such POJO may be tricky to implement, but then again should be doable. |
@JsonFormat(shape=Shape.OBJECT)
does not work
@JsonFormat(shape=Shape.OBJECT)
does not work@JsonFormat(shape=Shape.OBJECT)
class annotation
Ok: easy part is implemented so that class annotation like so: @JsonFormat(shape=JsonFormat.Shape.OBJECT)
@JsonIgnoreProperties({ "size" })
public class MyStrings {
public int getCount() {
return size();
}
public Collection<String> getValues() {
return values();
}
} would produce serialization like: { "count" : 3,
"value" : [ "a", "b", "c" ]
} Note that that this handling only support class-annotations (including mix-ins); per-property overrides are not supported as that is surprisingly difficult to support at this point. If support for property overrides is needed a new issue needs to be filed (also affected: |
I read here http://www.cowtowncoder.com/blog/archives/2013/10/entry_482.html that
@JsonFormat(shape=Shape.OBJECT)
must work for both collection and map types but my tests shows it doesn't work for a class that implements Map Interface.some digging in code approved my initial guess as there's no checking for
JsonFormat
inBasicSerializerFactory.buildMapSerializer
unlikebuildCollectionSerializer
method.now I am not sure that blog is official or not, but is there any technical reason to not implement this feature for Map or it's just forgotten?!
The text was updated successfully, but these errors were encountered: