Tag: 可解码

如何在Swift 4中编写一个可解码的JSON,其中密钥是dynamic的?

我有这样的JSON。 我需要使用Swift 4在我的iOS应用程序中创build相应的Decodable结构。 { "cherry": { "filling": "cherries and love", "goodWithIceCream": true, "madeBy": "my grandmother" }, "odd": { "filling": "rocks, I think?", "goodWithIceCream": false, "madeBy": "a child, maybe?" }, "super-chocolate": { "flavor": "german chocolate with chocolate shavings", "forABirthday": false, "madeBy": "the charming bakery up the street" } } 在制作Decodable Struct时需要帮助。 如何提到像cherry , odd和super-chocolate的未知键。