diff --git a/Sources/XMLCoder/Auxiliaries/Box/KeyedBox.swift b/Sources/XMLCoder/Auxiliaries/Box/KeyedBox.swift
index 0c2f692d..9930bfba 100644
--- a/Sources/XMLCoder/Auxiliaries/Box/KeyedBox.swift
+++ b/Sources/XMLCoder/Auxiliaries/Box/KeyedBox.swift
@@ -24,7 +24,7 @@ struct KeyedBox {
}
var value: SimpleBox? {
- return elements["value"].first as? SimpleBox
+ return elements[""].first as? SimpleBox
}
}
diff --git a/Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift b/Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift
index 77b45a5b..584b6e88 100644
--- a/Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift
+++ b/Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift
@@ -61,7 +61,7 @@ struct XMLCoderElement: Equatable {
// Handle attributed unkeyed value zap
// Value should be zap. Detect only when no other elements exist
if elements.isEmpty, let value = value {
- elements.append(StringBox(value), at: "value")
+ elements.append(StringBox(value), at: "")
}
return KeyedBox(elements: elements, attributes: attributes)
}
diff --git a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift
index d5b6f82a..81866711 100644
--- a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift
+++ b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift
@@ -97,7 +97,7 @@ class XMLDecoderImplementation: Decoder {
return KeyedDecodingContainer(XMLKeyedDecodingContainer(
referencing: self,
wrapping: SharedBox(KeyedBox(
- elements: KeyedStorage([("value", string)]),
+ elements: KeyedStorage([("", string)]),
attributes: KeyedStorage()
))
))
diff --git a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift
index e236db91..3c25da83 100644
--- a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift
+++ b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift
@@ -232,29 +232,11 @@ extension XMLKeyedDecodingContainer {
let elements = container
.withShared { keyedBox -> [KeyedBox.Element] in
- if ["value", ""].contains(key.stringValue) {
- let keyString = key.stringValue.isEmpty ? "value" : key.stringValue
- let value = keyedBox.elements[keyString]
- if !value.isEmpty {
- return value.map {
- if let singleKeyed = $0 as? SingleKeyedBox {
- return singleKeyed.element
- } else {
- return $0
- }
- }
- } else if let value = keyedBox.value {
- return [value]
+ keyedBox.elements[key.stringValue].map {
+ if let singleKeyed = $0 as? SingleKeyedBox {
+ return singleKeyed.element
} else {
- return []
- }
- } else {
- return keyedBox.elements[key.stringValue].map {
- if let singleKeyed = $0 as? SingleKeyedBox {
- return singleKeyed.element
- } else {
- return $0
- }
+ return $0
}
}
}
diff --git a/Tests/XMLCoderTests/AttributedIntrinsicTest.swift b/Tests/XMLCoderTests/AttributedIntrinsicTest.swift
index f303f0ce..926cf580 100644
--- a/Tests/XMLCoderTests/AttributedIntrinsicTest.swift
+++ b/Tests/XMLCoderTests/AttributedIntrinsicTest.swift
@@ -82,7 +82,7 @@ private struct Foo: Codable, DynamicNodeEncoding, Equatable {
enum CodingKeys: String, CodingKey {
case id
- case value
+ case value = ""
}
static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {
@@ -97,6 +97,10 @@ private struct Foo: Codable, DynamicNodeEncoding, Equatable {
private struct FooValue: Codable, Equatable {
let value: Int
+
+ enum CodingKeys: String, CodingKey {
+ case value = ""
+ }
}
private struct FooOptional: Codable, DynamicNodeEncoding, Equatable {
@@ -105,7 +109,7 @@ private struct FooOptional: Codable, DynamicNodeEncoding, Equatable {
enum CodingKeys: String, CodingKey {
case id
- case value
+ case value = ""
}
static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {
@@ -167,7 +171,7 @@ private struct PreviewImageTime: Codable, Equatable, DynamicNodeEncoding {
enum CodingKeys: String, CodingKey {
case format
- case value
+ case value = ""
}
static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {