다음 코드로 시도 ...
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) –