Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Clemmie-L opened this issue Mar 6, 2024 · 0 comments
Open

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

Clemmie-L opened this issue Mar 6, 2024 · 0 comments

Comments

@Clemmie-L
Copy link

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())")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant