?
Solved

Parse json in Swift IOS

Posted on 2014-10-09
2
Medium Priority
?
288 Views
Last Modified: 2015-01-08
Hello I have the follow json being returned below. I also have the code that I am using to produce this array. I I am not sure how to parse this data or pull out the pieces I need ..After println(jsonObject) I am not what to do put the array into separate variables.

Thanks


 let data = (results as NSString).dataUsingEncoding(NSUTF8StringEncoding)
        
       
        let jsonObject : AnyObject! = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: nil)
        
           println(jsonObject)
        
        if let userName: AnyObject = (((jsonObject as? NSArray)?[0] as? NSDictionary)?["activated"] as? NSDictionary)?["activated"]{
        }
       

Open in new window


(
        {
        activated = 1;
        "active_flag" = 0;
        address = "8212 Misty Shore Dr";
        "api_key" = 201404082058231;
        avatar = "brad.jpg";
        city = "West Chester";
        comments = "";
        created = "2014-04-07 22:18:00";
        "default_currency" = USD;
        email = "brad@datadesignsystems.com";
        "first_name" = Bradley;
        "icon_url" = "";
        "is_admin" = 1;
        "is_you" = 0;
        "last_login" = "2014-04-08 20:58:23";
        "last_name" = Amster;
        locale = "en_US";
        modified = "2014-04-08 20:58:23";
        "other_phone" = "513-766-9111";
        phone = "513-519-3258";
        result = success;
        "role_id" = 1;
        state = OH;
        status = 1;
        "timezone_name" = "America/New_York";
        zip = 45069;
    },
        {
        result = 0;
    }
)

Open in new window

0
Comment
Question by:bradley525
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
KRUNAL TAILOR earned 2000 total points
ID: 40430822
Hi bradley525,

Try, json-swift library.

Thanks & Regards,
Krunal T. Tailor
0
 

Author Closing Comment

by:bradley525
ID: 40538325
Thank you ..Sorry for the delay I did not realize this question was still open..Once I used Swift it did work.Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When Apple released Swift last year, the aim was to introduce a new programming language for Cocoa and Cocoa Touch that was fast, easy and effective, like the name connotes. Apple succeeded. Swift is designed to couple with Objective-C program…
How to take pictures with depth using iOS 10
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question