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
Solved

Parse json in Swift IOS

Posted on 2014-10-09
2
272 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
iPhone 6S IOS - Freeing up space in mail is NOT working 16 78
iOS10 upgrade 1 31
What Cisco IOS has CBAC support? 4 20
iOS Mail App for Exchange Accounts 4 20
Preface   In the first 100 days of the Macintosh release in January 1984, Apple sold 72,000 of the computers. Relatively cheap, easy-to-use personal computer with a graphical operating system. I've never seen this model. I did see this one:   …
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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