1

I receive this json string from my back-end :

{"exception":false,"success":true,"status":0,"message":"200-OK","confirmMessage":"null","html":"null","data":{"ID":"00000000-0000-0000-0000-000000000001","AccessLevel":"150","Username":"Administrator","PictureID":"00000000-0000-0000-0000-000000000001"}}

I can easy access to first level (exception, success, status, message, etc) with :

 let success:Bool = jsonData.valueForKey("success") as! Bool

My problem is when i try to read the different values into data level.

How can y read data.ID, data.Username, etc ?

LiTHiUM2525
  • 297
  • 3
  • 6
  • 19

1 Answers1

3

You can use the following "nested" valueForKey(..) approach:

jsonData.valueForKey("data").valueForKey("ID")

As an alternative, make use of NSDictionary as shown in this existing thread:

Community
  • 1
  • 1
dfrib
  • 70,367
  • 12
  • 127
  • 192