Skip to content

Compatible with SwiftyJSON #356

@zhangferry

Description

@zhangferry

Ran into a SwiftyJSON compatibility issue that only occurs when a ':' appears in the parsed string. Here's the code:

struct Model: Codable {
    let name: String
    let repo: JSON?
}

let model = Model(name: "Yams", repo: "git:Yams")
        
let encoder = YAMLEncoder()
let encodeStr = try! encoder.encode(model)
        
let newModel = try! decoder.decode(RuleRepo.self, from: encodeStr)
print(newModel.repo) // output: Optional(0)

the key is the : of git:Yams.

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