I am trying to parse JSON which is below
[ { "People": [ "Jack", "Jones", "Rock", "Taylor", "Rob" ] }, { "People": [ "Rose", "John" ] }, { "People": [ "Ted" ] } ]
into the array, which result in [[“Jack”, “Jones”, “Rock”, “Taylor”, “Rob”], [“Rose”, “John”], [“Ted”]]
which is an array of arrays.
I tried with the code below
if let path = Bundle.main.path(forResource: "People", ofType: "json") { let peoplesArray = try! JSONSerialization.jsonObject(with: Data(contentsOf: URL(fileURLWithPath: path)), options: JSONSerialization.ReadingOptions()) as? [AnyObject] for people in peoplesArray! { print(people) } }
when I type "people" I get o / p like
{ People = ( Jack, "Jones", "Rock", "Taylor", "Rob" ); } { People = ( "Rose", "John" ); } .....
I am confused how to make out when it "People" is repeated 3 times
Trying to display content in a UITableView, where my 1st cell has a "Jack" .. "Rob", and the second cell has a "Rose", "John" and a third cell as "Ted"
PLease will help me understand how to achieve this.