Hi,
response inlined.
Thanks,
Martin
On Sun, Apr 5, 2015 at 5:57 PM, Oleg Tsal-Tsalko <oleg.tsalko_at_gmail.com>
wrote:
> Hi guys,
>
> Feedback on generic mapping serialization examples:
> 1) Why there are no examples of actual usage of proposed
> Jsonb#toJson(Object, Type) method?
> I assume these examples should justify usage of this advanced method in
> those special/tricky cases where Jsonb#toJson(Object) method is not
> enough.
>
Will add example:
List<java.util.Optional<String>> expected =
Arrays.asList(Optional.empty(), Optional.ofNullable("first"),
Optional.of("second"));
String json = toJson(expected,
DefaultMappingGenerics.class.getField("listOfOptionalStringField").getGenericType());
assertEquals("[null,\"first\",\"second\"]",json);
> 2) Probably it was missed by me but are we going to support serialization
> of anonymous interfaces/classes implementations at all?
> As an example:
> myFunction = new FunctionalInterface<String>() {
>
> private String value = "initValue";
>
> @Override public String getValue() {
>
> return value;
>
> }
>
> public void setValue(String value) {
>
> this.value = value;
>
> }
>
> };
> assertEquals("{\"value\":\"initValue\"}", jsonb.toJson(myFunction));
> It doesn't look like valid scenarios to support.
> AFAIK, Gson lib doesn't support this...
>
Don't see reason why it is not valid scenario.
Genson supports it (with different result in some cases as proposed JSON-B)
:)
It would be helpful to hear some opinions from others on this topic.
> 3) Expected result in bounded example doesn't look right:
>
> assertEquals("{\"boundedSet\":[3],\"superList\":[{\"radius\":2.5}]}",
> jsonb.toJson(boundedGenericClass));
>
> I believe it should be:
>
> {"boundedSet":[3],"superList":[{"area":0.0,"radius":2.5}]}
>
>
Will fix asap.
> Have a great Easter!
>
> Thank you,
> Oleg
>
>