-
Notifications
You must be signed in to change notification settings - Fork 943
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
Error encoding array of Encodable #285
Comments
sorry if i am wrong let me try to help |
Sorry not sure I will understand @saroar. Are you asking if passing try response.setBody(json: Foo(bar: "Hello World")) If so, then yes it does work on its own. Only when passed inside an array literal does it then fail to parse into JSON. |
my working code |
check this one too
|
@saroar thank you for your input, however your code is doing something quite different to the problem I'm trying to explain. Essentially I'm saying when an array's elements all conform to You're right in saying you can pass a dictionary of |
@jwelton what are you trying to solve? |
Hello 👋
Not sure if this is expected or already a know issue, but I couldn't find anything in "issues". In a simplistic example, if you pass an
Encodable
object tosetBody
, then it encodes into JSON and returns the payload as expected. If however you change this so you're returning a array literal of Encodable's, then you get the following error:As it's an array of Encodable's, I would have expected the array to become Encodable too? As array normally gains this conformance automatically if all its elements are Encodable.
Here is a simple code example of the problem:
The text was updated successfully, but these errors were encountered: