android:parsing through json
<p>This is the Json string I have to parse.</p>

<pre><code>[{"Vehicle":{"display_name":"Anoop","id":"9","tank_capacity":"0.00"},
"Personnel":{"display_name":null,"id":null},
"DeviceLog":{"latitude":"11.182010","longitude":"75.870165","direction":"0","place":"0","speed":"0.00","stop_time":"15245","status":"1","tank_status":"0.00","mileage":"0.00","alerts":null,"kms_left":"0.00","gps_time":"16-07-2011 10:47:23"}}]
</code></pre>

<p>I tried following code.My aim is to get the values retrieved from json in logcat.</p>

<pre><code>JSONObject json=new JSONObject(result1);
JSONObject vehicle=json.getJSONObject("Vehicle");
JSONObject deviceLog=json.getJSONObject("DeviceLog");

String vehicleName=vehicle.getString("display_name");
int vehicleId=vehicle.getInt("id");

Double latitude=deviceLog.getDouble("latitude");
Double longitude=deviceLog.getDouble("longitude");

System.out.println(vehicleId +"  "+ vehicleName+ "  "+ latitude+"  "+longitude);
</code></pre>

<p>I am not sure with this code.This is what my logcat is showing.</p>

<pre><code>12-03 13:36:32.983: W/System.err(693): org.json.JSONException: A JSONObject text must begin with '{' at character 1 of [{"Vehicle":{"display_name":"galaxy","id":"14","tank_capacity":"0.00"},"Personnel":{"display_name":null,"id":null},"DeviceLog":{"latitude":"9.589788","longitude":"76.530592","direction":"0","place":"Kumarakom Lake Resort(0.12km)","speed":"0.00","stop_time":"704","status":"1","tank_status":"0.00","mileage":"0.00","alerts":null,"kms_left":"0.00","gps_time":"03-12-2011 14:12:12"}}]
12-03 13:36:33.054: W/System.err(693):  at org.json.JSONTokener.syntaxError(JSONTokener.java:448)
12-03 13:36:33.054: W/System.err(693):  at org.json.JSONObject.&lt;init&gt;(JSONObject.java:178)
12-03 13:36:33.063: W/System.err(693):  at org.json.JSONObject.&lt;init&gt;(JSONObject.java:246)
12-03 13:36:33.063: W/System.err(693):  at com.rekonsult.signon.Home.createvehicleSubList(Home.java:56)
12-03 13:36:33.063: W/System.err(693):  at com.rekonsult.signon.Home.onCreate(Home.java:35)
12-03 13:36:33.063: W/System.err(693):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
12-03 13:36:33.063: W/System.err(693):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
12-03 13:36:33.063: W/System.err(693):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
12-03 13:36:33.073: W/System.err(693):  at android.app.ActivityThread.access$2100(ActivityThread.java:116)
12-03 13:36:33.073: W/System.err(693):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
12-03 13:36:33.073: W/System.err(693):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 13:36:33.073: W/System.err(693):  at android.os.Looper.loop(Looper.java:123)
12-03 13:36:33.073: W/System.err(693):  at android.app.ActivityThread.main(ActivityThread.java:4203)
12-03 13:36:33.073: W/System.err(693):  at java.lang.reflect.Method.invokeNative(Native Method)
12-03 13:36:33.073: W/System.err(693):  at java.lang.reflect.Method.invoke(Method.java:521)
12-03 13:36:33.084: W/System.err(693):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
12-03 13:36:33.084: W/System.err(693):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
12-03 13:36:33.084: W/System.err(693):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>
