java - Convert HttpServletRequest to JSON as "UTF-8" -


i have method, converts httpservletrequest 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 error*/ }          return new jsonparser().parse(jb.tostring()).getasjsonobject();     } 

the problem is, how convert request "utf-8" encoding?

updated: checked, default reader takes request "iso-8859-1". how set parameter reader, took "utf-8".

i found solution myself. added top:

request.setcharacterencoding("utf-8"); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -