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

JsonDeserializer has something different #1326

Closed
LennyYi opened this issue May 24, 2018 · 2 comments
Closed

JsonDeserializer has something different #1326

LennyYi opened this issue May 24, 2018 · 2 comments
Labels

Comments

@LennyYi
Copy link

LennyYi commented May 24, 2018

public class User{ @Expose public String name; @JsonAdapter(value=StringPerCentJsonDeserializer.class) public String friendly; @Expose public String email; //User() //getter setter }
for StringPerCentJsonDeserializer's deserialize method just one line
return json.getAsString()+"%"

and in main method
String userStr = {"name":"Lenny","friendly":"20","email":"[email protected]"}; Gson gson = new GsonBuilder().create(); User user = (User)gson.fromJson(userStr,User.class); User user1 = new User("123","1","123"); String jsonstr = gson.toJson(user1); System.out.pirntln(str);
the print is {"name":"123"," friendly":{"value":["1"],"hash":0},"email":"123"},
I want {"name":"123"," friendly":"1","email":"123"}.why the friendly vary {"value":["1"],"hash":0}

@LennyYi
Copy link
Author

LennyYi commented May 24, 2018

My colleague tell me ,Maybe the @JsonAdapter in JsonSerializer influence attribute friendly regard as object;

@Marcono1234
Copy link
Collaborator

As mentioned in #1783 (comment), I assume this is the same issue as described by #1783. And that has apparently been fixed by #2435 now, therefore I am going to close this issue.

But please let us know if you can still reproduce this with the latest Gson code from the main branch, respectively the next upcoming Gson version (2.11.0 probably).

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

No branches or pull requests

2 participants