i have a string of this form:
[{"LocationsItems":[{"ItemId":4,"LocationId":3,"Qty":34},{"ItemId":19,"LocationId":3,"Qty":55}]}];
i need to convert this to an array of object, i tried this:
let data = convertedData.data(using: .utf8)!
do {
if let jsonArray = try JSONSerialization.jsonObject(with: data, options : .allowFragments) as? [Dictionary<String,Any>]
{
print(jsonArray)
} else {
print("bad json")
}
} catch let error as NSError {
print(error)
}
}
and returned this , which is an array of dictionaries:
[["LocationsItems": <__NSArrayI 0x600003a1c100>(
{
ItemId = 4;
LocationId = 3;
Qty = 34;
},
{
ItemId = 19;
LocationId = 3;
Qty = 55;
}
)
]]
how can i extract the objects from it? thanks