diff --git a/Sources/WebWorkerKit/JSValueEncoder.swift b/Sources/WebWorkerKit/JSValueEncoder.swift index 8b2133b..96af60b 100644 --- a/Sources/WebWorkerKit/JSValueEncoder.swift +++ b/Sources/WebWorkerKit/JSValueEncoder.swift @@ -134,9 +134,10 @@ private struct JSObjectKeyedEncodingContainer: KeyedEncodingCont func nestedContainer(keyedBy keyType: NestedKey.Type, forKey key: Key) -> KeyedEncodingContainer where NestedKey: CodingKey { - let encoder = JSValueEncoderImpl(codingPath: encoder.codingPath) - let container = JSObjectKeyedEncodingContainer(encoder: encoder) - encoder.value = .object(ObjectConstructor.new()) + let nestedEncoder = JSValueEncoderImpl(codingPath: encoder.codingPath) + let container = JSObjectKeyedEncodingContainer(encoder: nestedEncoder) + nestedEncoder.value = .object(ObjectConstructor.new()) + encoder.value[dynamicMember: key.stringValue] = nestedEncoder.value return KeyedEncodingContainer(container) }