代码之家  ›  专栏  ›  技术社区  ›  Jake2Finn

带包装键的复杂json到swift结构

  •  0
  • Jake2Finn  · 技术社区  · 7 年前

    JSON文件

    {
        "title": "this is a title",
        "children": {
            "attachment": {
                "results": [
                    {
                        "id": "att241845336",
                        "metadata": {
                            "mediaType": "application/vnd.ms-excel.sheet.macroEnabled.12"
                        },
                        "extensions": {
                            "fileSize": 430395,
                        }
                    },
                    {
                        "id": "att241844542",
                        "metadata": {
                            "mediaType": "image/png"
                        },
                        "extensions": {
                            "fileSize": 114781,
                        }
                    }
                ],
                "size": 25,
            },
            "_links": {
                "self": "https://example.com/rest/api/content/241845389/child"
            },
            "_expandable": {
                "comment": "/rest/api/content/241845389/child/comment",
                "page": "/rest/api/content/241845389/child/page"
            }
        },
        "_links": {
            "collection": "/rest/api/content",
        }
    }
    

    struct MetaMessage : Codable {
        struct Message : Codable {
            let title: String
            let children: [child]
            let _links: [link]
        }
    
        struct child {
            let attachment: [attachments]
            let _links: [link]
            let _expandable: [expandables]
        }
    
            struct attachments {
                let results: [result]
                let size: int
            }
    
                struct result {
                    let id: String
                    let metadata: [metadataSub]
                    let extensions: [extension]
                }
    
                    struct metadataSub {
                        let mediaType: Sting
                    }
    
                    struct extension {
                        let fileSize: Long
                    }
    
            struct link {
                let self: URL
            }
    
            struct expandables {
                let comment: String
                let page: String
            }
    
        struct expandables {
            let collection: String
        }
    }
    
    0 回复  |  直到 7 年前