Skip to content

version:0.3.3 时奔溃。希望能找找原因。 #24

@Clemmie-L

Description

@Clemmie-L

import CodableWrapper

struct LocationModel: Codable {

@Codec("Id")
var id: String? = nil
@Codec("Value")
var value: String? = nil 
@Codec("Children")
var child: [LocationModel]? = nil

}

Test:

    let jsonString2 =
    "[{\"Value\":null,\"Label\":\"State/Province\",\"Id\":\"a0Mp0000007ANEoEAO\",\"Children\":[{\"Value\":\"Bangkok\",\"Label\":\"City\",\"Id\":\"a0Mp0000007ANe7EAG\",\"Children\":[{\"Value\":\"Bang Kapi\",\"Label\":\"District\",\"Id\":\"a0Mp0000007ANeCEAW\",\"Children\":null}]}]}]".data(using: .utf8)!
    
    let decoder = JSONDecoder()
    let model = try! decoder.decode([LocationModel].self, from: jsonString2)
    logInfo("json = \(model.toJSONString())")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions