Skip to content

JsonDeserializer has something different #1326

@LennyYi

Description

@LennyYi

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions