KeyValueCoder icon indicating copy to clipboard operation
KeyValueCoder copied to clipboard

Questions about additional coding strategies

Open chazeon opened this issue 10 months ago • 1 comments

Hi, I really appreciate this package—it’s been very useful!

I was wondering if you have any plans to support additional coding/decoding strategies similar to those provided by JSONEncoder and JSONDecoder, such as JSONDecoder.DateDecodingStrategy and JSONDecoder.KeyDecodingStrategy?

I would love to hear your plans on this since I am thinking about extending some of this functionality for use in my own code, or maybe contributing back to this repo if I get some of it done.

Thanks!

chazeon avatar Feb 27 '25 16:02 chazeon

Hi @chazeon, I think this is a great idea and happy to add this support.

I have recently updated NilCodingStrategy and IntDecodingStrategy to be Sendable so I would just expect these new strategies to also be Sendable.

So would something like this work?

enum KeyDecodingStrategy: Sendable {
   ...
   case custom(@Sendable ([any CodingKey]) -> any CodingKey)
}

swhitty avatar Mar 03 '25 07:03 swhitty

Would be good with snake case converted

oO0oO0oO0o0o00 avatar Jun 13 '25 10:06 oO0oO0oO0o0o00

snake_case is now supported on main branch https://github.com/swhitty/KeyValueCoder/pull/12

Update: available in 0.8.0 release

swhitty avatar Jun 18 '25 04:06 swhitty

DateEncoding/DecodingStrategy is now supported on main branch https://github.com/swhitty/KeyValueCoder/pull/14

Update: Available in the 0.9.0 release

swhitty avatar Jul 20 '25 04:07 swhitty

Thank you!

chazeon avatar Jul 23 '25 15:07 chazeon