-
Notifications
You must be signed in to change notification settings - Fork 128
URIEncoder does not correctly encode primitive collections #292
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
Comments
@bfrearson can you provide an example of the Codable type? Which one doesn't work, and what's the error? typealias Foo = [String] or struct Foo: Codable {
var bar: [String]
} I'd expect the former to work, but possibly not the latter. |
Ping @bfrearson, when you have a moment, I'm wondering if you remember which case from the above was failing for you, thanks! |
Hey, sorry for the delay - been super slammed at the moment! It would be the second option that failed: struct Foo: Codable {
var bar: [String]
} |
Yes, that's expected. Nested containers are not supported, only top level containers. So the array has to be the top level item, and the name |
It's also possible you're trying to do #259? |
Yes it looks as if this covers the same issue. Tbh this was an abstract thought I had while working on the encoder, rather than a real world barrier that I hit. I don't think any of the APIs I'm currently using personally need to support this, but I think there should definitely be support for handling them. |
Understood, thank you. Let me close this issue then and reference it from #259, as it already covers this then. |
Trying to encode a primitive collection (e.g. an array of Strings) from a Codable type fails because the URIEncoder rejects nested object types.
It would be beneficial to support this, as there we may have query items or forms which contain multiple values for the same key. I believe
URIDecoder
already does support collecting identical keys into a collection.The text was updated successfully, but these errors were encountered: