次のコードのようにしてみ...
do {
//Convert to Data
let jsonData = try JSONSerialization.data(withJSONObject: dictionaryArray, options: JSONSerialization.WritingOptions.prettyPrinted)
//Do this for print data only otherwise skip
if let JSONString = String(data: jsonData, encoding: String.Encoding.utf8) {
print(JSONString)
}
//In production, you usually want to try and cast as the root data structure. Here we are casting as a dictionary. If the root object is an array cast as [AnyObject].
var json = try JSONSerialization.jsonObject(with: jsonData, options: JSONSerialization.ReadingOptions.mutableContainers) as? [String: AnyObject]
} catch {
print(error.description)
}
は、あなたのコードを含めてもらえますか? –
これは迅速な質問の場合は、関連するタグを追加してください。また、試行中に表示される特定のエラーを提供する必要があります。 –
[配列をすぐにJSON文字列に変換]の可能な複製(http://stackoverflow.com/questions/28325268/convert-array-to-json-string-in-swift) –