Comments (3)
That's super interesting, thanks for the tip! The accompanying bugs.swift.org post has a lot of good info on that as well. I'll spend some time digging into these nuances and see what I can come up with.
from bettercodable.
@Stevenmagdy Appreciate the offer but no thanks. I'm still on the fence with supporting something similar to KeyedContainer. There are a lot of bugs-used-as-features in regards to Dictionary de/en/coding right now so I've been hoping to see Swift make a decision here or tell us this is the bed we must lie in.
from bettercodable.
@Strobocop I have this extension in my code
extension KeyedDecodingContainer {
func decodeRawKeyedDict<K: RawRepresentable, V: Decodable>(
_ type: [K: V].Type,
forKey key: Key
) throws -> [K: V] where K.RawValue: Decodable & Hashable {
let rawDict = try decode([K.RawValue: V].self, forKey: key)
let tupleArray = rawDict.compactMap { key, value in
K(rawValue: key).flatMap { ($0, value) }
}
return .init(tupleArray) { first, second in first }
}
}
@marksands Open for a PR?
from bettercodable.
Related Issues (20)
- Rename RawValue to DefaultValue in DefaultCodingStrategy
- Composing `LossyArray` with `DefaultEmptyArray` HOT 2
- Any ideas why I keep getting this error with cocoapods?
- podspec file should change version to 0.3.0 HOT 2
- Default Empty Lossy Array HOT 3
- LosslessValue not working as excepted from Int to String value HOT 6
- Add DefaultNil similar to DefaultTrue/False HOT 2
- could increase log output ,when decode or encode error happened HOT 2
- Uncodable property wrapper HOT 1
- @DefaultFalse cannot deal string number HOT 2
- JSONEncoder's `dateEncodingStrategy` ignored for default `Date` HOT 1
- Xcode 13 linking against a dylib which is not safe for use in application extensions HOT 1
- Decoding Date? HOT 4
- Feature: Decode logical `Bool` into a real `Bool` HOT 1
- protocol CodableEnumeration for enum HOT 4
- Missing property in nested object fails the whole decoding of nested object
- How to deal with optional Date? HOT 2
- Are you prepared to support field mapping?
- Removed CocoaPod and add via SPM. Now getting "Framework not found BetterCodable" HOT 1
- Create a new release HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bettercodable.