다음 코드가 있고 SwiftyJSON을 사용하여 값을 얻으려고합니다.
let string =
"""
{"ResponseMetadata": {"RequestId": "b5d6ecad-e050-4d1f-8429-74a2775a6fe9", "HTTPStatusCode": 200, "HTTPHeaders": {"x-amzn-requestid": "b5d6ecad-e050-4d1f-8429-74a2775a6fe9", "content-type": "application/json", "content-length": "271", "date": "Tue, 22 Dec 2020 22:45:17 GMT"}, "RetryAttempts": 0}, "numberOfRecordsUpdated": 0, "records": [[{"stringValue": "6998DFFE-A9CF-4BEA-86AD-C356BB865E27"}, {"stringValue": "[email protected]"}, {"stringValue": "David"}, {"stringValue": "Craine"}, {"stringValue": "dcraine"}, {"stringValue": "vendor1"}, {"stringValue": "vendor1_werw8"}]]}
"""
let body = JSON(string)
print(">>>>>>>>> \(body["records"])")
body [ "records"]에 대해 null을 반환합니다.
https://jsonformatter.curiousconcept.com/#을 사용하여이 응답의 유효성을 검사 했으므로 올바른 형식이라고 가정합니다. 누구든지 제발 도와 줄 수 있습니까?
다음 줄을 변경해보십시오.
let body = JSON(string)
그리고 전화 init(parseJSON:)
의 초기화 JSON
가이 소요 String
과 같이 매개 변수로 :
let body = JSON(parseJSON: string)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다