Learn Courses My Dashboard

Custom App Error

I am working on one of my own apps. I am trying to decode a JSON file into an array of dictionaries with a string key and an any value. It gives me an array saying signal SIGABRT. Here is the line of code that I am talking about.

let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! [[String:Any]]

Can you tell me how I can fix or resolve this issue?

Hi @Pratham_Hebbar

Check to ensure you do not have an object with a Referencing outlet not connected.


Ok thanks will do and tell you what happens.

Sorry for the late reply! I did what you told me to do and the error is not because I don’t have any IBOutlets not connected.

The outermost symbol of your JSON is [, which indicates it is a JSON array, not JSON object.

You cannot convert JSON array into NSDictionary

I figured out the issue with the app. There was an error in the JSON file so I had to correct/fix that.
But thanks for your help and getting back to me regardless! It is much appreciated!

P.S. I am not suggesting your advice is wrong and I am sorry and apologize if my reply gives you that impression.

Well done, I should have thought ion that first! Thats has caught me a couple times, especially when I forget to run the json code through an online json checker.

Glad you got it sorted out.


1 Like

Thank you again for the help and for the kind words!