Q:

Json Parse not working properly but works on jsontest

I am a new programmer, i am trying to build an app with Json.
I created Json parser class and in my main activity i have the following code :
 String url = "http://echo.jsontest.com/key/value/one/two";
                        JSONObject json = jParser.getJSONFromUrl(url);

one = json.getString(gridArray.get(lekeres).getTitle()); // one has the good value "two"
This works great. BUT
if i change url to : https://api.myjson.com/bins/3f8d2
 which is exactly the same code as in the jsontest, one doesn't have "two" . I searched for hours but i don't know why this is happening. I did nothing but change the url. The contest is the same...

A:

Since I don't know how is your parser. I made a quick test and can read both link normally with this code:

        try {
            //url = new URL(""http://echo.jsontest.com/key/value/one/two2"); 
            url = new URL("https://api.myjson.com/bins/3f8d2");
            InputStream is = url.openStream();
            JSONObject json = null;
            BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
            StringBuilder sb = new StringBuilder();
            int cp;
            while ((cp = rd.read()) != -1) {
                sb.append((char) cp);
            }
            String jsonText = sb.toString();
            json = new JSONObject(jsonText);

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

This is more examples: http://en.proft.me/2013/12/5/how-parse-json-java/.
You can make your getJSONFromUrl similarly. Otherwise like other suggest try without https://.

