JSON parsing problem

前端 未结 4 384
臣服心动
臣服心动 2020-12-09 23:51

i am trying to Json parsing in my android app the link is https://www.buzzador.com/apps/present_software/webservice/index.php?op=ProductQ&campaign_id=607&userid=1077

相关标签:
4条回答
  • 2020-12-10 00:37
      char[] utf8 = null;
                StringBuilder properString = new StringBuilder("");
    
                utf8 = Response.toCharArray();
    
                for (int i = 0; i < utf8.length; i++) {
                    if ((int) utf8[i] < 65000) {
                        properString.append(utf8[i]);
                    }
                }
      System.out.println("Response of Login::"
                            + properString.toString());
    
    0 讨论(0)
  • 2020-12-10 00:45

    To remove character like (\n) or unwanted character in json string used commons-lang3:3.4 library in program . i used this class to remove unwanted character in json string "StringEscapeUtils.unescapeJava(string)".

    this will help you.

    0 讨论(0)
  • 2020-12-10 00:53

    Had similar problem. At first my app was working great on both androids 4.0+ and 4.0- (2.3.3 2.2 etc). after a revision i have that problem. JSonarray could parse on 2.3.3

    PROBLEM: Json STRING (response from server) comes with a character ' in front so actual response= '[{"1":"omg"}] and not the correct one [{"1":"omg"}]

    Solution: if string dosent start with [ then edit response string (remove the ' character)

      if (result.startsWith("["))
          {
    
    
    
          }
          else
          {
              result= result.substring(1);
          }
    

    after then everything worked fine for me

    0 讨论(0)
  • 2020-12-10 00:54

    If you are a using json-lib-2.4 as library, which I assume, you can parse strings with :

    JSONSerializer.toJSON(yourString).toString() 
    

    instead of using the JsonObject class

    0 讨论(0)
提交回复
热议问题