Thanks for the response. I should have stated that this is specifically on 
my Android app. The JSON response is coming from my server. 

On Tuesday, March 11, 2014 1:00:44 PM UTC-7, TreKing wrote:
>
> This is not really Android specific, so you might benefit more from a 
> general forum, like StackOverflow.
>
> Still, here's one idea. Keep a Map<String, Integer> that tracks the count 
> of each ID.
> First, iterate over the response and update the map as you encounter each 
> ID (set to 1 if does not already exist, else + 1).
> Then iterate over your ArrayList and grab the value from the map for each 
> ID you have.
>
>
> On Mon, Mar 10, 2014 at 10:25 PM, Kyle Phillips 
> <carbon...@gmail.com<javascript:>
> > wrote:
>
>> I create an `Arraylist Hashmap` (shown below) by parsing a JSON response 
>> from Google Places API. Than I take the "id" strings and send them to my 
>> server to look for users with matching ids in my DB. Any matches I return 
>> the users in a JSON response (shown below). 
>>
>> Now what I need to do is iterate over the JSON response and count the 
>> number of ID matches and update the "numbercheck" value in the hashmap to 
>> the appropriate number. For example in the JSON Response there is 2 
>> occurrences of the id "339fd8e9a6aee4567764275e4d0827568fb499e5" so I would 
>> update numbercheck from null to 2 on Place 1. I'm not sure how to go about 
>> this. Should I parse the JSON response into its own map and than compare 
>> the two maps? Any help would appreciated. 
>>
>> `Arraylist Hashamp Example:`
>>
>>     [
>>     {
>>         lastcheck=null,
>>         id=339fd8e9a6aee4567764275e4d0827568fb499e5,
>>         vicinity=1314NWGlisanSt,
>>         New York,
>>         numbercheck=null,
>>         name=Place 1
>>     },
>>     {
>>         lastcheck=null,
>>         id=d42061acd095772c3e646819fb47aea5b03e4705,
>>         vicinity=1338NWHoytSt,
>>         Portland,
>>         numbercheck=null,
>>         name=Place 2
>>     }
>>     ]
>>
>> `JSON Response Example:`
>>
>>     {
>>     "tag": "userList",
>>     "success": 1,
>>     "error": 0,
>>     "placeMatches": {
>>         "userObjects": [
>>             {
>>                 "id": "339fd8e9a6aee4567764275e4d0827568fb499e5",
>>                 "dob": "2014-06-06",
>>                 "gender": "Female",
>>                 "status": "NoSay",
>>                 "image": "image/image.jpg",
>>                 "lastcheck": "26:30:29"
>>             },
>>             {
>>                 "id": "339fd8e9a6aee4567764275e4d0827568fb499e5",
>>                 "dob": "2014-01-11",
>>                 "gender": "Female",
>>                 "status": "Taken",
>>                 "image": "image/image.jpg",
>>                 "lastcheck": "26:30:29"
>>             },
>>             {
>>                 "id": "d42061acd095772c3e646819fb47aea5b03e4705",
>>                 "dob": "2014-04-16",
>>                 "gender": "Male",
>>                 "status": "NoSay",
>>                 "image": "image/image.jpg",
>>                 "lastcheck": "26:30:29"
>>             },
>>             {
>>                 "id": "d42061acd095772c3e646819fb47aea5b03e4705",
>>                 "dob": "2013-04-19",
>>                 "gender": "Female",
>>                 "status": "NoSay",
>>                 "image": "image/image.jpg",
>>                 "lastcheck": "26:30:29"
>>             },
>>             {
>>                 "id": "d42061acd095772c3e646819fb47aea5b03e4705",
>>                 "dob": "2014-01-29",
>>                 "gender": "Female",
>>                 "status": "Single",
>>                 "image": "image/image.jpg",
>>                 "lastcheck": "26:30:29"
>>             }
>>          ]
>>     }
>>     }
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to 
>> android-d...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com <javascript:>
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to android-developers+unsubscr...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago 
> transit tracking app for Android-powered devices
>  

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to