# AlamoFire What I need is a Dictionary not a Array of Dictionary

**URL:** <https://forums.kodeco.com/t/alamofire-what-i-need-is-a-dictionary-not-a-array-of-dictionary/10081>\
**Category:** Swift\
**Created:** [March 17, 2016, 3:41pm UTC](https://forums.kodeco.com/t/alamofire-what-i-need-is-a-dictionary-not-a-array-of-dictionary/10081 "2016-03-17T15:41:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hcri50](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@hcri50](https://forums.kodeco.com/u/hcri50)\
**Post date:** [March 17, 2016, 3:41pm UTC](https://forums.kodeco.com/t/alamofire-what-i-need-is-a-dictionary-not-a-array-of-dictionary/10081/1 "2016-03-17T15:41:19Z")

</div>

I am lost on how to save my JSON as a Dictionary not as (Array of Dictionary)

I got this working perfectly as a Array of Dictionaries with this URL ( [http://api.androidhive.info/contacts/](http://api.androidhive.info/contacts/) )  
How can I capture as a pure dictionary ??

override func viewDidLoad() {  
super.viewDidLoad()

```
    Alamofire.request(.GET, "http://logger.lumberjacksystem.com/index.php/api/list_stories/74/74/").responseJSON { (responseData) -> Void in
        let swiftyJsonVar = JSON(responseData.result.value!)
        
        if let resData = swiftyJsonVar["contacts"].arrayObject {
            self.arrayOfDictionary = resData as! [[String:AnyObject]]
        }
       
        if self.arrayOfDictionary.count > 0 {
            self.tblJSON.reloadData()
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![narrativium](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/narrativium/32/110937_2.png) [@narrativium](https://forums.kodeco.com/u/narrativium)\
**Post date:** [March 17, 2016, 5:50pm UTC](https://forums.kodeco.com/t/alamofire-what-i-need-is-a-dictionary-not-a-array-of-dictionary/10081/2 "2016-03-17T17:50:06Z")

</div>

Which part of the data structure are you trying to save?

Your `swiftyJsonVar` is a JSON dictionary with one entry, which is an array of dictionaries. Are you trying to capture the root dictionary, or one of those in the array?

---

<div class="post-metadata">

**Author:** ![hcri50](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@hcri50](https://forums.kodeco.com/u/hcri50)\
**Post date:** [March 19, 2016, 6:36am UTC](https://forums.kodeco.com/t/alamofire-what-i-need-is-a-dictionary-not-a-array-of-dictionary/10081/3 "2016-03-19T06:36:06Z")

</div>

Thank you for your reply. Click on the URL below please

URL ( [http://api.androidhive.info/contacts/1](http://api.androidhive.info/contacts/1) )

You will see that the Array of Dictionary is based on “Contacts”

And the URL below is a pure Dictionary not an Array of Dictionary

[http://logger.lumberjacksystem.com/index.php/api/list\_stories/74/74/](http://logger.lumberjacksystem.com/index.php/api/list_stories/74/74/)

I am able to to extract the Dictionary from Contacts no problem. But I do not understand how to extract a Dictionary from the JSON.

---

<div class="post-metadata">

**Author:** ![hcri50](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@hcri50](https://forums.kodeco.com/u/hcri50)\
**Post date:** [March 19, 2016, 7:17am UTC](https://forums.kodeco.com/t/alamofire-what-i-need-is-a-dictionary-not-a-array-of-dictionary/10081/4 "2016-03-19T07:17:26Z")

</div>

([Dropbox - File Deleted](https://www.dropbox.com/s/fcgv4y59leo24rd/AlamoAndSwiftyJSON.zip?dl=0))  
This will help you to see what I am trying to accomplish.

---

<div class="post-metadata">

**Author:** ![narrativium](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/narrativium/32/110937_2.png) [@narrativium](https://forums.kodeco.com/u/narrativium)\
**Post date:** [March 23, 2016, 12:58pm UTC](https://forums.kodeco.com/t/alamofire-what-i-need-is-a-dictionary-not-a-array-of-dictionary/10081/5 "2016-03-23T12:58:55Z")

</div>

A post was split to a new topic: [Cocoapods for contacts problem](https://forums.kodeco.com/t/cocoapods-for-contacts-problem/10793)
