Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9049643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:27:02+00:00 2026-06-16T12:27:02+00:00

I am using jsonparser to parse data and images obtained from json response. When

  • 0

I am using jsonparser to parse data and images obtained from json response. When i include this code to parse image output is D/AndroidRuntime(441): Shutting down VM
D/dalvikvm(441): Debugger has detached; object registry had 1 entries

JSONArray attachments = json.getJSONArray(KEY_ATTACHMENTS);
                for(int j = 0; j < attachments.length(); j++){
                    JSONObject d = attachments.getJSONObject(j);
                    JSONObject images = d.getJSONObject(KEY_IMAGES);
                    String thumbnail = d.getString(KEY_THUMB_URL);

                    JSONObject thumnails = d.getJSONObject(KEY_THUMB_URL);
                    String url = author.getString(KEY_URL);

Am’i going wrong in parsing the content? can any body help Images are displaying along with data in output. my JSON response is

{
"status": "ok",

"posts": [
    {
        "id": 2498,
        "title": "jigsaw lamp imported from thailand",
        "content": "<p>Hi. It&#8217;s a invitation to have a look at a unique lamp shade called jigsaw lamp from thailand. Available in multi attractive colours.</p>\n",
        "date": "2012-12-26 09:48:15",
         "author": {
            "name": "Tapas123456",
                        },
            "attachments": [
            {
                "description": "",
                "caption": "",
                "mime_type": "image/jpeg",
                "images": {

                    "thumbnail": {
                        "url": "http://site/wp-content/uploads/2012/12/646675-50x47.jpg",

                    }
                }
            },...............

following is the code

     public class CustomizedListView extends Activity {
   JSONArray posts = null;

  // All static variables
  static final String URL = "http://website";



  static final String KEY_POSTS = "posts";
  static final String KEY_ID = "id";
  static final String KEY_TITLE = "title";
  static final String KEY_DATE = "date";
  static final String KEY_CONTENT = "content";
  static final String KEY_AUTHOR = "author";
  static final String KEY_NAME = "name";
  static final String KEY_ATTACHMENTS = "attachments";
  static final String KEY_THUMB_URL = "thumbnail";
  static final String KEY_IMAGES = "images";
  static final String KEY_URL = "url";

  ListView list;
     LazyAdapter adapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();


    // Creating JSON Parser instance
            JSONParser jParser = new JSONParser();

            // getting JSON string from URL
            JSONObject json = jParser.getJSONFromUrl(URL);
            try {
            posts = json.getJSONArray(KEY_POSTS);
    // looping through all song nodes <song>
            for(int i = 0; i < posts.length(); i++){
                JSONObject c = posts.getJSONObject(i);
                // Storing each json item in variable
                String id = c.getString(KEY_ID);
                String title = c.getString(KEY_TITLE);
                String date = c.getString(KEY_DATE);
                String content = c.getString(KEY_CONTENT);

                // Phone number is agin  JSON Object
                JSONObject author = c.getJSONObject(KEY_AUTHOR);
                String name = author.getString(KEY_NAME);

                JSONArray attachments = json.getJSONArray(KEY_ATTACHMENTS);
                for(int j = 0; j < attachments.length(); j++){
                    JSONObject d = attachments.getJSONObject(j);
                    JSONObject images = d.getJSONObject(KEY_IMAGES);
                    String thumbnail = d.getString(KEY_THUMB_URL);

                    JSONObject thumnails = d.getJSONObject(KEY_THUMB_URL);
                    String url = author.getString(KEY_URL);
                }
        // creating new HashMap
        HashMap<String, String> map = new HashMap<String, String>();

        // adding each child node to HashMap key => value
        map.put(KEY_ID, id);
        map.put(KEY_TITLE, title);
        map.put(KEY_DATE, date);
        map.put(KEY_NAME, name);
        map.put(KEY_CONTENT, content);

        // adding HashList to ArrayList
        songsList.add(map);
            }   
            } catch (JSONException e) {
                e.printStackTrace();

                }


    list=(ListView)findViewById(R.id.list);

    // Getting adapter by passing json data ArrayList
    adapter=new LazyAdapter(this, songsList);        
    list.setAdapter(adapter);


    // Click event for single list row
    list.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {


        }
         });        
          } 
            }

LazyAdapter.java

public class LazyAdapter extends BaseAdapter {

private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 

public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
    activity = a;
    data=d;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.size();
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.list_row, null);

    TextView title = (TextView)vi.findViewById(R.id.title); // title
    TextView date = (TextView)vi.findViewById(R.id.artist); // artist name
    TextView content = (TextView)vi.findViewById(R.id.duration);  // duration
    TextView name = (TextView)vi.findViewById(R.id.name); 
    // duration
    ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image

    HashMap<String, String> song = new HashMap<String, String>();
    song = data.get(position);


    ListView list;
    // Setting all values in listview
    title.setText(song.get(CustomizedListView.KEY_TITLE));
    date.setText(song.get(CustomizedListView.KEY_DATE));
    content.setText(song.get(CustomizedListView.KEY_CONTENT));
    name.setText(song.get(CustomizedListView.KEY_NAME));

    imageLoader.DisplayImage(song.get(CustomizedListView.KEY_URL), thumb_image);
    return vi;
        }
        }

logcat error
12-29 14:42:59.152: D/AndroidRuntime(449): CheckJNI is ON
12-29 14:42:59.273: D/AndroidRuntime(449): — registering native functions —
12-29 14:42:59.732: D/AndroidRuntime(449): Shutting down VM
12-29 14:42:59.742: D/dalvikvm(449): Debugger has detached; object registry had 1 entries
12-29 14:42:59.752: I/AndroidRuntime(449): NOTE: attach of thread ‘Binder Thread #3’ failed
12-29 14:43:00.172: D/AndroidRuntime(457): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
12-29 14:43:00.172: D/AndroidRuntime(457): CheckJNI is ON
12-29 14:43:00.292: D/AndroidRuntime(457): — registering native functions —
12-29 14:43:00.772: I/ActivityManager(58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.androidhive/.CustomizedListView }
12-29 14:43:00.783: D/AndroidRuntime(457): Shutting down VM
12-29 14:43:00.783: D/dalvikvm(457): Debugger has detached; object registry had 1 entries
12-29 14:43:00.792: I/AndroidRuntime(457): NOTE: attach of thread ‘Binder Thread #3’ failed

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:27:03+00:00Added an answer on June 16, 2026 at 12:27 pm

    Parse current json as:

       JSONObject json=new JSONObject("pass your json string here");
    
      JSONArray arrjson = json.getJSONArray("posts");
    
       for(int j = 0; j < arrjson.length(); j++){
            JSONObject jsonimages = attachments.getJSONObject(j);
    
           JSONArray attachmentsimages = jsonimages.getJSONArray("attachments");
    
          for(int i = 0; i < attachmentsimages.length(); i++){
    
               JSONObject imagesjson = attachmentsimages.getJSONObject(i);
    
               JSONObject imagesjsonnew = imagesjson.getJSONObject("images");
               JSONObject thumnailsimages = imagesjsonnew.getJSONObject("thumbnail");
    
               String url = thumnailsimages.getString("url");
         }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse the JSON response from Wordnik's API. This is built
I am using imageloader to load thumbnail images from json response, there are lots
Using this to load the json var jsonParsed = JSON.parse(localStorage.getItem('test')); Using this to save
I am using the json parser from json.org to handle data from my application.
I am using jQuery.ajax(...) to retrieve JSON data from an ASP.NET MVC service. When
I was using the SBJSON files from this JSON tutorial and then I tried
I want to parse this JSON string using Gson {name:name,type:[a,b,c]} is it possible? 1st
this the JSON data that i want to parse in my application: { viewdeal:[
I'm using the combination of json_encode (PHP) and JSON.parser (Javascript from json.org) for passing
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.