You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all I am using restygwt 2.0.2 which I have recently upgraded from 1.X.
Since the upgrade, I am forced to defined every Dto that has extends with proper JsonSubTypes and JsonTypeNames.
Following is the scenario that is falling for me
Given I have the super class, A as below.
@JsonSubTypes({@Type(A.class), @Type(B.class)})
@JsonTypeName("A")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@class")
public class A {
private String code;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
and a subclass B as below:
@JsonTypeName("B")
public class B extends A {
private String desc;
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc= desc;
}
}
Using Spring MVC (version 3.2.0.RELEASE) I have the following on the server side.
@RequestMapping(method = GET, produces = JSON_TYPE)
public ResponseEntity<List<A>> getA(@RequestParam(CODE) String code) {
A dto= new A();
dto.setCode("test code")
List<A> dtoList= Lists.newArrayList(dto);
return new ResponseEntity<List<A>>(dtoList, HttpStatus.OK);
}
When the json string is returned from the server it will be
[
{"code":"test code"}
]
As observed it is missing the "@Class":A which will eventually cause the ResponseFormatException because the generated JsonEncoderDecoder for A will check for sourceName and expects it to be not NULL because A is not a leaf due to B being its subtype.
Is this an actual problem with the way I defined the subtypes? or
Is this a problem with Spring MVC's MappingJackson2HttpMessageConverter not having the "@Class" property in the json response? or
Is this as actual issue with the JsonEncoderDecoderClassCreator where it should also consider the case where there potentially no sourceName is provided?
The text was updated successfully, but these errors were encountered:
nloke
pushed a commit
to nloke/resty-gwt
that referenced
this issue
May 7, 2015
The problem is described at resty-gwt#249
This fix is that by default if sourceName is null, we will use the decoding based on the classtype that we are generating the JsonEncocderDecoderClass for
First of all I am using restygwt 2.0.2 which I have recently upgraded from 1.X.
Since the upgrade, I am forced to defined every Dto that has extends with proper JsonSubTypes and JsonTypeNames.
Following is the scenario that is falling for me
Given I have the super class, A as below.
and a subclass B as below:
Using Spring MVC (version 3.2.0.RELEASE) I have the following on the server side.
When the json string is returned from the server it will be
As observed it is missing the "@Class":A which will eventually cause the ResponseFormatException because the generated JsonEncoderDecoder for A will check for sourceName and expects it to be not NULL because A is not a leaf due to B being its subtype.
Is this an actual problem with the way I defined the subtypes? or
Is this a problem with Spring MVC's MappingJackson2HttpMessageConverter not having the "@Class" property in the json response? or
Is this as actual issue with the JsonEncoderDecoderClassCreator where it should also consider the case where there potentially no sourceName is provided?
The text was updated successfully, but these errors were encountered: