-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the bug of not decoding nested Array
of Object
#69
Conversation
fixed the bug that could not decode nested Array of Objects.
remove console code
The situation is more complicated than I thought before. |
With this PR, struct Formdata: Decodable, Equatable {
struct NestedFormdata: Decodable, Equatable {
struct AnotherNestedFormdata: Decodable, Equatable {
let int: Int
let string: String
let strings: [String]
}
let int: String
let string: Int
let strings: [String]
let anotherNestedFormdata: AnotherNestedFormdata
let anotherNestedFormdataList: [AnotherNestedFormdata]
}
let nestedFormdata: [NestedFormdata]
} Fixed the bug that when it comes to But struct Formdata: Content {
struct NestedFormdata: Content {
let strings: [String]
}
let nestedFormdata: [NestedFormdata]
} it cannot distinguish Formdata(nestedFormdata: [
.init(strings: ["1", "2"]),
.init(strings: ["3", "4"])
]) from Formdata(nestedFormdata: [
.init(strings: ["1", "2", "3", "4"]),
]) (let me know if I am wrong) |
@chocoford I'll need to get into the details at a later point when I have more time but with regards to |
I found So far, I haven't found any information about that from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like we shouldn't try to guess which element of an array a part belongs to but rather require an index except for maybe the last part of the name. So nestedFormdata[0][strings][]
for example. And we should change the encoder to match that (but there just output indexes for all).
} | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -423,38 +423,107 @@ class MultipartTests: XCTestCase { | |||
|
|||
XCTAssertEqual(data, expected) | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a great idea. So, we have two options: allow or disallow |
So far, I've allowed optional index in non-last part. |
@chocoford hi! Apologies for the long hiatus. As you can see in #70 I have been busy rethinking the Codable implementation as the existing one isn't as correct as I'd like. I'm pretty happy with how that turned out. However, it would make this PR hard to adapt. |
@siemensikkema It doesn't matter, as long as the problem can be solved. So far, I hadn't seen any issues. The redesign is great by the way. |
Fix the problem that
Multipart-kit
could not decode nestedArray
of Object mentioned in #67.