Skip to content

Conversation

swhitty
Copy link
Owner

@swhitty swhitty commented Jun 18, 2025

Keys can be encoded to snake_case by setting the strategy:

var encoder = KeyValueEncoder()
encoder.keyEncodingStrategy = .convertToSnakeCase

// ["first_name": "fish", "surname": "chips"]
let dict = try encoder.encode(Person(firstName: "fish", surname: "chips))

And decoded from snake_case:

var decoder = KeyValueDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase

let person = try decoder.decode(Person.self, from: dict)

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.89%. Comparing base (900eaff) to head (2bc5f43).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #12      +/-   ##
==========================================
+ Coverage   99.77%   99.89%   +0.11%     
==========================================
  Files           3        3              
  Lines         891      951      +60     
==========================================
+ Hits          889      950      +61     
+ Misses          2        1       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@swhitty swhitty merged commit cc58455 into main Jun 18, 2025
23 of 24 checks passed
@swhitty swhitty deleted the KeyEncodingDecodingStrategies branch July 1, 2025 02:55
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

Successfully merging this pull request may close these issues.

2 participants