# @propertyWrapper & CodingKeys

**URL:** <https://forums.swift.org/t/propertywrapper-codingkeys/26489>\
**Category:** Using Swift\
**Tags:** codable, properties\
**Created:** [June 30, 2019, 4:26pm UTC](https://forums.swift.org/t/propertywrapper-codingkeys/26489 "2019-06-30T16:26:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcprux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/marcprux/32/12098_2.png) [@marcprux](https://forums.swift.org/u/marcprux)\
**Post date:** [June 30, 2019, 4:26pm UTC](https://forums.swift.org/t/propertywrapper-codingkeys/26489/1 "2019-06-30T16:26:38Z")

</div>

I have a no-op `Wrapped` `properyDelegate` in Swift 5.1 (Xcode Version 11.0 beta 2 (11M337n)):

```swift
@propertyWrapper struct Wrapped<T: Codable> : Codable {
    var value: T
    init(initialValue value: T) { self.value = value }
}

```

I then include it in a `Codable` instance:

```swift
struct Thing : Codable {
    var num: Int = 1
    @Wrapped var misc = Misc()

    struct Misc : Codable { }
}

```

When I encode it, the `misc` property is encoded with the dollar sign: `$misc`. I'd like to rename that to something else, but when I add in a `CodingKeys` implementation:

```swift
struct Thing : Codable {
    var num: Int = 1
    @Wrapped var misc = Misc()

    struct Misc : Codable { }

    enum CodingKeys : String, CodingKey { case num, misc = "stuff" }
}

```

I get the compile error: `CodingKey case 'misc' does not match any stored properties`.

And trying to name the key `$misc` gives another error (both with and without backtick escapes): `Cannot declare entity '$misc' with a '$' prefix`

Is there any way to rename a `@propertyWrapper` coding key, short of overriding the entire `encode(to:)` implementation?

---

<div class="post-metadata">

**Author:** ![cukr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cukr/32/889_2.png) [@cukr](https://forums.swift.org/u/cukr)\
**Post date:** [June 30, 2019, 4:40pm UTC](https://forums.swift.org/t/propertywrapper-codingkeys/26489/2 "2019-06-30T16:40:54Z")

</div>

The [current plan](https://github.com/apple/swift-evolution/blob/master/proposals/0258-property-wrappers.md#codable-hashable-and-equatable-synthesis) is that the wrapper would be encoded under the original property name without any prefixes, "misc" in your case.

The whole @propertyWrapper proposal is still in flux, you can ask, or even give suggestions how it should work in the review thread: [SE-0258: Property Wrappers (third review)](https://forums.swift.org/t/se-0258-property-wrappers-third-review/26399)
