1

I tried sending japanese letters via json, however, the json value returned is "jspString":"???????". What am I doing wrong? Thanks!

JSONObject info = new JSONObject();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

info.put("japString", "よやかなゆひま");
nameValuePairs.add(new BasicNameValuePair("info", info.toString()));
postCard.setEntity(new UrlEncodedFormEntity(nameValuePairs));   
postResponse = postCardClient.execute(postCard);
postResponseEntity = postResponse.getEntity();
String printResult = EntityUtils.toString(postResponseEntity);
OckhamsRazor
  • 4,824
  • 13
  • 51
  • 88

2 Answers2

2

Found the answer: just add toString() to info.put("japString", "よやかなゆひま".toString());. Internally, it escapes the unicode characters.

OckhamsRazor
  • 4,824
  • 13
  • 51
  • 88
-1

just use postCard.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")) instead hope this will help

Ezeki
  • 149
  • 1
  • 2