0

I am trying to parse a json that contians RTL(right to left) language, in my case hebrew, using JSONObject (org.json.JSONObject):

JSONObject row = requestBody.getJSONObject("row"); //requestBody - json, row - the object I want to parse

and the String with the hebrew text:

String addr = "";
if(row.has("m_addr")){ //checking if the object has key name 
  addr = row.getString("m_addr"); //setting value
}

when viewing the result I get:

System.out.println(addr); // :x?x?x?x?x?

anyone knows how to set UTF-8 when parsing JSONObject? or any other soulation?

Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114
  • Let me try. could be. – Itsik Mauyhas May 18 '16 at 11:49
  • Yes it was the same problem, thanks. – Itsik Mauyhas May 18 '16 at 11:52
  • What is `requestBody`? Is that a `JSONObject`? If so, how is that constructed? Are you reading from a `Stream` or `Writer` somewhere and constructing it by passing in that string for it to parse? If so, it appears that you will need to make sure that the input source you're reading from is properly handling the UTF-8 conversion. – BillRobertson42 May 18 '16 at 12:02
  • the 'reuestBody' is http post request data, after parsing string it is JSONObject, it is not utf-8 encoded, I found a simler question, thanks. – Itsik Mauyhas May 18 '16 at 12:12

0 Answers0