-4

this is my JSON

enter image description here]1

I can try to parse the Json But it's not parsing this is the code

if let Media_list = jsonData["staffData"] as? NSDictionary
{
    print("this can call")

    for i in 0 ..< Media_list.count {
        if let kid = Media_list[i] as? NSDictionary
        {
            print("this the calling ")

            let dataurl = kid["url"] as? String
            self.urldummy.append(dataurl!)

            print("dataurl",dataurl as Any)                            

            let staffid = kid["staffId"]as? String
            self.staffidDummy.append(staffid!)                   
            let update = kid["updatedDate"]as? String    
            self.UpdateDummy.append(update!)                       
        }
    }                            
}

I want parse Json data and append to the array, pls help me....!

Alexey Kozhevnikov
  • 4,249
  • 1
  • 21
  • 29
Dhruv
  • 13
  • 1
  • 7
  • 2
    `for i in 0 ..< Media_list.count` while `Media_list` is a Dictionary? Also, avoid Foundation Stuff (NSStuff) on Swift 3. – Larme Sep 05 '17 at 11:44
  • @Aleksey if I can set Media_list[i] as? NSDictionary to Media_list[i] as? Any its going inside – Dhruv Sep 05 '17 at 11:48
  • it's showing this error: Type 'Any' has no subscript members – Dhruv Sep 05 '17 at 11:49

1 Answers1

-2

do Directly as

let Media_list = jsonData["staffData"] as? NSDictionary
let dataurl = Media_list["url"] as? String
Vikas Rajput
  • 1,754
  • 1
  • 14
  • 26