Solved

Parse json in Swift IOS

Posted on 2014-10-09
2
275 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
iOS 10.1.1 2 59
Jailbroken Apple TV 2 has to buffer every 1 minute while playing moves 5 91
Receipt Printer for web based app 3 110
A good practical skill 10 55
I recently went through the process of creating an installable image of an iPhone mobile app (an .ipa file) that beta testers could load onto their test devices. The process involved quite a few steps, but both Appcelerator and Diawi.org had decent …
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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