I am currently using a code (best answer on a question) I found here everything works properly until you give it a japanese String
input.
I thought the UTF-8
charset would do the trick but I am not really sure what part of the code does not allow japanese characters to be serialized.
For example if I serialize something basic like "ひらがな"
it will output garbage characters.
What I am doing is something like
String serialized = serialize("ひらがな");
String deserialized = deserialize(serialized, new TypeToken<String>() {}.getType());
System.out.println(deserialized);
But I am getting a garbage deserialized
.
Can someone please shed some light? Thank you.
I don't know the exact answer to your question, but I can say I had a similar problem and here was my solution. Maybe it's a hint for you:
I am only using GSON for deserialization. I had to change the following code from
json = gson.fromJson(new InputStreamReader(is), parseType);
to
json = gson.fromJson(new InputStreamReader(is,"UTF-8"), parseType);
So the issue was in my input stream reader, not GSON per se. I wonder if you need to use a string reader for deserialization or something. Sorry I can't give you a more specific answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With