title: return json from server
body: <p>How to return data from database in json  via webpage. I saw some pages has .json extention or something like that. Is there some tool that returns it like that?</p>
  
  <p>Previously I checked few tutorials where data was returned via php script and readed using java code. But for me it didn't worked, java code would read html code not the data that I would like to transfer. </p>
  
  <pre><code>try{
          jArray = new JSONArray(result);
          JSONObject json_data= null;
          for(int i=0;i&lt;jArray.length();i++){
                 json_data = jArray.getJSONObject(i);
                 ct_id=json_data.getInt("CITY_ID");
                 System.out.println(ct_id);
                 ct_name=json_data.getString("CITY_NAME");
                 System.out.println(ct_name);
             }
          }
          catch(JSONException e1){
            Toast.makeText(getBaseContext(), "No City Found" ,Toast.LENGTH_LONG).show();
          }
  </code></pre>
  
  <p>Exception would always show up. So I printed lines that it gets and it html code. How to fix it? </p>