Funny I just replaced the use of jsonobject with Jackson json because of it
being faster to stream process json with and using less memory. There are
many good examples via Google with regards to using Jackson and android
that may solve your problem and reduce your apps memory use and parsing
time.
On Jan 16, 2013 3:08 PM, "geet handa" <geethand...@gmail.com> wrote:

> Hi every one,
>
>                     I am working on Json Parsing....In that I  am
> facing problem in Convert String into JsonObject....Please Help
> me!!!!!!
>
>                     Here is the code I got
>
>         class MyTask extends AsyncTask<String, Void, String> {
>
>                 ProgressDialog pDialog;
>
>                 @Override
>                 protected void onPreExecute() {
>                         super.onPreExecute();
>
>                         pDialog = new ProgressDialog(MainActivity.this);
>                         pDialog.setMessage("Loading...");
>                         pDialog.setCancelable(false);
>                         pDialog.show();
>                 }
>
>                 @Override
>                 protected String doInBackground(String... params) {
>                         return Utils.getJSONString(params[0]);
>                 }
>
>                 @Override
>                 protected void onPostExecute(String result) {
>                         super.onPostExecute(result);
>
>                         if (null != pDialog && pDialog.isShowing()) {
>                                 pDialog.dismiss();
>                         }
>
>                         if (null == result || result.length() == 0) {
>                                 showToast("No data found from web!!!");
>                                 MainActivity.this.finish();
>                         } else {
>
>                                 try {
>
> System.out.println("Monaaaaaaaaaaaaa"+result);
>
> Toast.makeText(getApplicationContext(), ""+result, 1000).show();
>
>                                         JSONObject mainJson = new
> JSONObject(result);
>
>
> System.out.println("Monaaaaaaaaaaaaa"+mainJson);
>
>                                         JSONArray jsonArray =
> mainJson.getJSONArray(ARRAY_NAME);
>                                         for (int i = 0; i <
> jsonArray.length(); i++) {
>                                                 JSONObject objJson =
> jsonArray.getJSONObject(i);
>
>                                                 Item objItem = new Item();
>
>
> objItem.setId(objJson.getInt(ID));
>
> objItem.setName(objJson.getString(NAME));
> //
>  objItem.setCity(objJson.getString(CITY));
> //
>  objItem.setGender(objJson.getString(GENDER));
> //
>  objItem.setAge(objJson.getInt(AGE));
> //
>  objItem.setBirthdate(objJson.getString(BIRTH_DATE));
>
>                                                 arrayOfList.add(objItem);
>
>                                         }
>                                 } catch (JSONException e) {
>                                         e.printStackTrace();
>                                 }
>
> Thanks.....
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to