ArrayList in JAVA/Android, how to print only the value

I have a contactList = new ArrayList<>(); where I store information in this format: "name", value_for_name.

I populate my contactList inside this function:

protected Void doInBackground(Void... arg0) {
            HttpHandler sh = new HttpHandler();

            // Making a request to url and getting response
            String jsonStr = sh.makeServiceCall(url);

            Log.e(TAG, "Response from url: " + jsonStr);

            if (jsonStr != null) {
                try {
                    JSONObject jsonObj = new JSONObject(jsonStr);

                    // Getting JSON Array node
                    JSONArray contacts = jsonObj.getJSONArray("results");

                    // looping through All Results
                    for (int i = 0; i < contacts.length(); i++) {
                        JSONObject c = contacts.getJSONObject(i);

                        String icon = c.getString("icon");
                        String id = c.getString("id");
                        String name = c.getString("name");

                        // tmp hash map for single contact
                        HashMap<String, String> contact = new HashMap<>();

                        // adding each child node to HashMap key => value
                        // contact.put("id", id);
                        contact.put("name", name);
                        // contact.put("email", icon);

                        // adding contact to contact list

                } catch (final JSONException e) {
                    Log.e(TAG, "Json parsing error: " + e.getMessage());
                    runOnUiThread(new Runnable() {
                        public void run() {
                                    "Json parsing error: " + e.getMessage(),

            } else {
                Log.e(TAG, "Couldn't get json from server.");
                runOnUiThread(new Runnable() {
                    public void run() {
                                "Couldn't get json from server. Check LogCat for possible errors!",


            return null;

Open in new window

The problem is that when I try to print a value:


Open in new window

The output is in this format: {name="Foo"}

I only want to print Foo I tried also with:

Open in new window

but I always get the whole string: {name="Foo"}

Can you help me, please? Do I really need to parse the string?
Rocco GalatiR&D EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Edit: Just a guess, but I think contactList.get(position) returns the whole object (Map), instead of a specific key within that Map.  What happens if you grab the key "name" instead?


Open in new window

or ...


Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rocco GalatiR&D EngineerAuthor Commented:
it worked very well!!! thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.