Incorrect Json in output toJson method of Gson library

Denis Bolshakov

I use method toJson for generate json from object. I encountered an error with the translation of the object into the json view .

    SingnUpRq singnUpRq = new SingnUpRq("lsjdflkdjslfk", "ZCqKckIpwvxtLFZz3TlUln5RqUpEB5U43imi7PSYv6UBY/bLvKQBSDIxXR5cAKnK+CU+UiyBB998fRJRvGJJDw==");

    String postBody = gson.toJson(singnUpRq);

    postBody (problem with last symbols == :{"DeviceId":"lsjdflkdjslfk","RefreshToken":"ZCqKckIpwvxtLFZz3TlUln5RqUpEB5U43imi7PSYv6UBY/bLvKQBSDIxXR5cAKnK+CU+UiyBB998fRJRvGJJDw\u003d\u003d"}

Why is this problem may occurr? How can I resolve this problem?

Denis Bolshakov

I found solution here: https://github.com/google/gson/issues/203

Instead use constructor new Gson(), need use

Gson gson = new GsonBuilder().disableHtmlEscaping().create();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related