0

i have a nested jsonobject in a jsonobject

this nested jsonobject is {"key":"value"} format.

Ex: this "key" is "attribute_pa_%d9%85%d9%82%d8%a7%d8%b3"

the basic jsonobject is

 {
    "name": 
     {
            "attribute_pa_%d9%85%d9%82%d8%a7%d8%b3":"4-5"
     }, 
     "stock":0
}

I get it in my javascript:

JSONObject attribute = object.getJSONObject("name");
Iterator iterator = attribute.keys();
String key = (String)iterator.next();
String issue = attribute.getString(key);

Those encoded chars are Arabic characters.

My question is; How can I decode those characters; So instad of having "attribute_pa_%d9%85%d9%82%d8%a7%d8%b3" I would have "attribute_pa_القياس".

mayo
  • 3,845
  • 1
  • 32
  • 42
K_nalis
  • 11
  • 5
  • 2
    the tag should be `Java` not `Javascript`. – Omar Einea Dec 29 '17 at 21:35
  • take a look at this https://stackoverflow.com/questions/5396560/how-do-i-convert-special-utf-8-chars-to-their-iso-8859-1-equivalent-using-javasc – Tareq Dec 29 '17 at 21:38
  • As they said this solution is the best for me Srtring result = java.net.URLDecoder.decode(key, "UTF-8"); – K_nalis Dec 29 '17 at 23:15

0 Answers0