Results 1 to 2 of 2
  1. #1
    brunob.15 is offline Member
    Join Date
    Jul 2014
    Posts
    1
    Rep Power
    0

    Default Error reading web service with android

    Hi there!
    I'm trying to read some JSON data from a web service and show it in a Toast.
    This is the JSON array I'm trying to read:

    Java Code:
    {"ProximoPartido":[{"rival":"Nacional","cancha":"Stockolmo","hora":"21.15","fecha":"Viernes 30","estado":"Pendiente"}]}
    And this is the code I have:
    Java Code:
    private class ReadJSONFeedTask extends AsyncTask
                <String, Void, String> {
            protected String doInBackground(String... urls) {
                return readJSONFeed(urls[0]);
            }
    
            protected void onPostExecute(String result) {
                try {
                    JSONObject jsonObject = new JSONObject(result);
                    JSONArray data = jsonObject.getJSONArray(result);
                    JSONObject ProximosPartidos =data.getJSONObject(0);
                    Toast.makeText(getBaseContext(),
                            ProximosPartidos.getString("rival") +
                                    " - " + ProximosPartidos.getString("fecha"),
                            Toast.LENGTH_SHORT).show();
                } catch (Exception e) {
                    Log.d("ReadJSONFeedTask", e.getLocalizedMessage());
                }
            }
        }
    But I get this error: "No value for {"ProximoPartido":[{"rival":"Nacional","cancha":"Stockolmo","hora":"2 1.15","fecha":"Viernes 30","estado":"Pendiente"}]}"

    Any idea of what I'm doing wrong?
    Thanks!!

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Error reading web service with android

    I don't know what logger you're using, but most will accept the whole exception so that you will get the stack trace as well.
    Without it you are going to be guessing exactly what the problem is.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 02-28-2014, 12:33 PM
  2. Replies: 2
    Last Post: 11-28-2013, 07:35 PM
  3. Replies: 7
    Last Post: 03-05-2012, 06:26 PM
  4. Transfer a file from Web Service to Android
    By vannam28071988 in forum Android
    Replies: 1
    Last Post: 11-16-2011, 01:00 AM
  5. Android read/write to database on a web service.
    By SeanieSortMeOut in forum Android
    Replies: 1
    Last Post: 02-05-2011, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •