Skip to content
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

Object to String return "null" #1795

Closed
authorZhao opened this issue Oct 9, 2020 · 2 comments
Closed

Object to String return "null" #1795

authorZhao opened this issue Oct 9, 2020 · 2 comments

Comments

@authorZhao
Copy link

version 2.8.5

    private void sendFollowerActivity(){
@Data class ActivityPersonAuditResultDTO{private Long actId;private Integer auditStatus;}
        Long actId = 1906050000052709L;
        ActivityPersonAuditResultDTO dto = new ActivityPersonAuditResultDTO();
        dto.setActId(actId);
        dto.setAuditStatus(10);
        String gosn = new Gson().toJson(dto);//gosn is "null"
        String fastjson = JSON.toJSONString(dto); //fastjson is ok,{"actId":1906050000052709,"auditStatus":10}
}
@lyubomyr-shaydariv
Copy link
Contributor

Local classes are not supported. See #1510 and https://github.com/google/gson/blob/master/UserGuide.md#finer-points-with-objects .

@Marcono1234
Copy link
Collaborator

Closing because as mentioned above the issue is that you are using local classes, and there are already other GitHub issues about this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants