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
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}
The text was updated successfully, but these errors were encountered:
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).
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}
The text was updated successfully, but these errors were encountered: