Skip to content

Commit

Permalink
Merge pull request #49 from outfoxx/fix/ref-encoding
Browse files Browse the repository at this point in the history
Use KeyedNestedEncoder in CustomRef.encode
  • Loading branch information
kdubb committed Feb 12, 2023
2 parents 48fcb56 + 4745dc4 commit 176c788
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/PotentCodables/Refs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ public struct CustomRef<TKP: TypeKeyProvider, VKP: ValueKeyProvider, TI: TypeInd
if let value = value {
var container = encoder.container(keyedBy: AnyCodingKey.self)
try container.encode(TI.typeId(of: type(of: value)), forKey: TKP.typeKey)
try container.encode((value as? Encodable).unsafelyUnwrapped, forKey: VKP.valueKey)
let encodableValue = (value as? Encodable).unsafelyUnwrapped
try encodableValue.encode(to: KeyedNestedEncoder(key: VKP.valueKey, container: container, encoder: encoder))
}
else {
var container = encoder.singleValueContainer()
Expand Down

0 comments on commit 176c788

Please sign in to comment.