You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A standalone XML element with attributed intrinsic works. When it's embedded in another element, it fails.
// This passes
letpreviewTime=""" <?xml version="1.0" encoding="UTF-8"?> <preview_image_time format="24/999 1000/nonDrop">00:00:17:01</preview_image_time>""".data(using:.utf8)!
letdecoder=XMLDecoder()
decoder.errorContextLength =10letmetadata1=try decoder.decode(PreviewImageTime.self, from: previewTime)print(metadata1)
// this does not pass
letpreview=""" <?xml version="1.0" encoding="UTF-8"?> <app_preview display_target="iOS-6.5-in" position="1"> <preview_image_time format="24/999 1000/nonDrop">00:00:17:01</preview_image_time> </app_preview>""".data(using:.utf8)!
letmetadata2=try decoder.decode(AppPreview.self, from: preview)print(metadata2)
structs:
structAppPreview:Codable{vardisplayTarget:Stringvarposition:IntvarpreviewImageTime:PreviewImageTime
// var dataFile: DataFile
enumCodingKeys:String,CodingKey{case displayTarget ="display_target"case position
case previewImageTime ="preview_image_time"
// case dataFile = "data_file"
}}structPreviewImageTime:Codable,DynamicNodeEncoding{varformat:Stringvarvalue:StringenumCodingKeys:String,CodingKey{case format
case value
}staticfunc nodeEncoding(forKey key:CodingKey)->XMLEncoder.NodeEncoding{print("node encoding")
switch key {caseCodingKeys.format:return.attribute
default:return.element
}}}
The text was updated successfully, but these errors were encountered:
Existing `flatten` implementation wasn't correctly handling element values, this is now fixed.
Fixes#78
* Fix nested attributed intrinsic
* Cleanup new `AppPreview` test
@thecb4 this should be now fixed and is verified with a test based on the code you've provided. Please let me know if this is still reproducible for you in master.
As reported in #12 by @thecb4:
A standalone XML element with attributed intrinsic works. When it's embedded in another element, it fails.
structs:
The text was updated successfully, but these errors were encountered: