CodableWrapper icon indicating copy to clipboard operation
CodableWrapper copied to clipboard

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

Open Clemmie-L opened this issue 1 year ago • 0 comments

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())")

Clemmie-L avatar Mar 06 '24 07:03 Clemmie-L