신속한 디코드 프로토콜이 '-'문자로 어떻게 작동합니까? 내 스위프트 클래스에서Swift 4 '-'문자로 json을 디코드하십시오.
[{
"trigger": {
"url-filter": "webkit.org",
"resource-type": ["image"]
},
"action": {
"selector": "#logo",
"type": "block"
}
}]
: 예를 들어
struct blockerJson : Decodable {
let action : action
let trigger : trigger
struct action : Decodable {
let selector : String
let type : String
}
struct trigger : Decodable {
let urlFilter : String
let resourceType : String
}
}
나는 클래스를 변경하는 방법을 알고하지 않습니다하지만, JSON은 변경할 수 없습니다 ...
다른 지원되는 문자처럼 작동합니다. – vadian
당신은 당신이 가지고있는 json 응답에서 필요에 따라 스스로해야합니다. –
[Swift 4의 디코드 가능 프로토콜로 사용자 정의 키를 사용하려면 어떻게합니까?] (https://stackoverflow.com/questions/44396500/how-do-i-use-custom-keys-with-swift-4s-decodable -protocol) – Hamish