Solved

Parse json in Swift IOS

Posted on 2014-10-09
2
262 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
2 Comments
 
LVL 12

Accepted Solution

by:
KRUNAL TAILOR earned 500 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
     Intro      In this article, I will show you how to parse a JSON in Swift using an open source library called SwiftyJSON (https://github.com/SwiftyJSON/SwiftyJSON). If you haven't heard of a JSON before, it stands for JavaScript Object Notation…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now