0

This is a follow up question of Removing linebreak from php json output.I couldn't find out what was making that problem but i somehow got rid of value <br ...JSONException.

The Issue

when i use

String url = "http://192.168.32.1/Aafois/notice.php?isBatch=2010&section1='IT'";

I get what i want i.e parsing the JSON to my android app.However when i use

String URL="http://192.168.32.1/Aafois/notice.php?isBatch="+isbatch+"&section1="+"'"+section1+"'";

I get Value of java.lang.string can't be converted to JSONArray...JSONException.So obviously there must be some problem there in this previous line.isbatch is an integer variable and secton1 is a string variable which is URL encoded to utf-8.

P.S

I need single quote ' before and after the variable section1 as the url goes like http://192.168.32.1/Aafois/notice.php?isBatch=2010&section1='IT'.

Community
  • 1
  • 1
Sash_KP
  • 5,551
  • 2
  • 25
  • 34
  • 1
    Can you print the resulting value of `URL` in the second case ? – Daniel Feb 27 '14 at 15:33
  • Your simple question solved my problem.I checked those variables and they were returning null.Modified what needed.Worked as expected.Thanks. – Sash_KP Feb 27 '14 at 18:11

3 Answers3

0

I think of your variables is a JSONArray. To concatenate everything, it tries to turn your String into a JSONArray, which is not possible as your string is not JSON but part of a URL.

PlasmaPower
  • 1,864
  • 15
  • 18
  • I checked those variables and they were returning null.Modified what needed.Worked as expected.Thanks. – Sash_KP Feb 27 '14 at 18:11
0

I checked for the variables isBatch and section1.They were returning null.Modified what was needed.Worked as expected.No more JSONException.

Sash_KP
  • 5,551
  • 2
  • 25
  • 34
0

I solved the issue with this

    String batch= "C";
    String section = "2";
    String URL = "http://192.168.32.1/Aafois/notice.php?isBatch=";
    URL= URL.concat(batch+"& section ="+section);