Solved

Parse json in Swift IOS

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

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 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…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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