0

I am trying to call an object inside a JSON array using Alamofire. I can get Alamofire to parse my file however, I cannot find the way to get a specific parameter out.

if I use:

Alamofire.request(.GET, "https://example.com//users_result.json")
            .responseJSON { response in

                print(response.result)   // result of response serialization

                if let JSON = response.result.value {
                    print(JSON.count)
                    print("JSON: \(JSON[1])")
                }
        }

the code prints out:

> SUCCESS 4 JSON: {
>     Age = 22;
>     Email = "annahswift@gmail.com";
>     Location = "New York";
>     MyText = "Love Music";
>     Name = Annah;
>     Password = 123456;
>     REF = 003;
>     "Reg_Date" = "2015-07-30";
>     Sex = Female;
>     Surname = Swift; }

Now, how can I call the parameter 'name'?

print("JSON: \(JSON[1][4])") // nil ??
rmaddy
  • 314,917
  • 42
  • 532
  • 579
SNos
  • 3,430
  • 5
  • 42
  • 92
  • Possible duplicate of [How to parse JSON response from Alamofire API in Swift?](http://stackoverflow.com/questions/26114831/how-to-parse-json-response-from-alamofire-api-in-swift) (This one, or one of the thousands available.) – Eric Aya Oct 27 '15 at 18:04
  • And also: [Swift documentation, The basics: Dictionaries](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html#//apple_ref/doc/uid/TP40014097-CH8-ID105) – Eric Aya Oct 27 '15 at 18:06

1 Answers1

0
 print("Response data: \(JSON[1]["Name"] as! String)")
SNos
  • 3,430
  • 5
  • 42
  • 92