json parser get exception during obtaining from web service with json format
<p>I am confused why I am having these errors where in fact the web service from my gae application i have created is returning exactly the same what json format should be.</p>

<p>you can check this url <a href="http://dashproapp.appspot.com/rest/user" rel="nofollow">http://dashproapp.appspot.com/rest/user</a>
it is returning json format.</p>

<p>here is the code to consume the results</p>

<p>JSONParser jParser = new JSONParser();</p>

<pre><code>    // getting JSON string from URL
    JSONObject json = jParser.getJSONFromUrl(url_path);

    try {
        // Getting Array of users
        userlist = json.getJSONArray(TAG_USER);

        // looping through All USERS obtain from results
        for(int i = 0; i &lt; userlist.length(); i++){
            JSONObject c = userlist.getJSONObject(i);

            // Storing each json item in variable
            String address = c.getString(TAG_ADDRESS);              
            String id = c.getString(TAG_ID);
            String age = c.getString(TAG_AGE);
            String fname = c.getString(TAG_FNAME);
            String lname = c.getString(TAG_LNAME);
            String username = c.getString(TAG_USERNAME);
            String password = c.getString(TAG_PASSWORD);
</code></pre>

<p>this is the error
Error parsing data org.json.JSONException: Value 

<p>//on log cat 
12-13 09:20:18.632: I/ApplicationPackageManager(32494): cscCountry is not German : XTC
12-13 09:20:32.289: D/dalvikvm(32494): GC_CONCURRENT freed 107K, 45% free 3155K/5639K, external 499K/517K, paused 4ms+15ms
12-13 09:20:32.632: E/JSON Parser(32494): Error parsing data org.json.JSONException: Value Server of type java.lang.String cannot be converted to JSONObject
12-13 09:20:32.640: D/AndroidRuntime(32494): Shutting down VM
12-13 09:20:32.640: W/dalvikvm(32494): threadid=1: thread exiting with uncaught exception (group=0x40018578)
12-13 09:20:32.640: E/AndroidRuntime(32494): FATAL EXCEPTION: main
12-13 09:20:32.640: E/AndroidRuntime(32494): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pruce.aps.estateportalconsume/com.pruce.aps.estateportalconsume.MainActivity}: java.lang.NullPointerException
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.os.Looper.loop(Looper.java:130)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.app.ActivityThread.main(ActivityThread.java:3687)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at java.lang.reflect.Method.invokeNative(Native Method)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at java.lang.reflect.Method.invoke(Method.java:507)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at dalvik.system.NativeStart.main(Native Method)
12-13 09:20:32.640: E/AndroidRuntime(32494): Caused by: java.lang.NullPointerException
12-13 09:20:32.640: E/AndroidRuntime(32494):    at com.pruce.aps.estateportalconsume.MainActivity.onCreate(MainActivity.java:54)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-13 09:20:32.640: E/AndroidRuntime(32494):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
12-13 09:20:32.640: E/AndroidRuntime(32494):    ... 11 more</p>

<p>and I used the tutorials that i found here <a href="http://www.androidhive.info/2012/01/android-json-parsing-tutorial/" rel="nofollow">http://www.androidhive.info/2012/01/android-json-parsing-tutorial/</a>
to consume the json in my android app. I'm trying to use this architecture is such a way that i'll be using GAE as my server (accept data, return data in json format). </p>

<p>and here the whole main class
private static String url_path = "http://dashproapp.appspot.com/rest/user/";</p>

<pre><code>private static final String TAG_USER = "user_list";
private static final String TAG_ID = "id"; 
private static String TAG_FNAME = "firstname";
private static String TAG_LNAME = "lastname";
private static String TAG_AGE = "age";
private static String TAG_ADDRESS = "address";
private static String TAG_USERNAME = "username";
private static String TAG_PASSWORD = "password";


//store in array first
JSONArray userlist = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Hashmap for ListView
    ArrayList&lt;HashMap&lt;String, String&gt;&gt; userList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();

    // instantiate json for parsing list obtain from above
    JSONParser jParser = new JSONParser();

    // getting JSON string from URL
    JSONObject json = jParser.getJSONFromUrl(url_path);
     //ArrayList&lt;JSONObject&gt; arrays = new ArrayList&lt;JSONObject&gt;();
    try {
        // Getting Array of users
        userlist = json.getJSONArray(TAG_USER);

        // looping through All USERS obtain from results
        for(int i = 0; i &lt; userlist.length(); i++){
            JSONObject c = userlist.getJSONObject(i);

            //arrays.add(c);                            
            // Storing each json item in variable
            String address = c.getString(TAG_ADDRESS);              
            String id = c.getString(TAG_ID);
            String age = c.getString(TAG_AGE);
            String fname = c.getString(TAG_FNAME);
            String lname = c.getString(TAG_LNAME);
            String username = c.getString(TAG_USERNAME);
            String password = c.getString(TAG_PASSWORD);


            // creating new HashMap
            HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

            // adding each child node to HashMap key =&gt; value
            map.put(TAG_ADDRESS, address);
            map.put(TAG_ID, id);
            map.put(TAG_AGE, age);
            map.put(TAG_FNAME, fname);
            map.put(TAG_LNAME, lname);
            map.put(TAG_USERNAME, username);
            map.put(TAG_PASSWORD, password);

            // adding HashList to ArrayList
            userList.add(map);
        }
        //JSONObject[] jsons = new JSONObject[arrays.size()];
        //arrays.toArray(jsons);

        //System.out.print(arrays.get(1));

    } catch (JSONException e) {
        e.printStackTrace();
    }
</code></pre>
