I have method, which converts HttpServletRequest to JSON format:
public JsonObject requestToJson(HttpServletRequest request){
StringBuffer jb = new StringBuffer();
String line = null;
try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null)
jb.append(line);
} catch (Exception e) { /*report an error*/ }
return new JsonParser().parse(jb.toString()).getAsJsonObject();
}
The problem is, how to convert request as "UTF-8" encoding?
UPDATED: I checked, by default reader takes request as "ISO-8859-1". How to set parameter to reader, that it took it as "UTF-8".
I found solution myself. I just added to top:
request.setCharacterEncoding("UTF-8");
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