-
Notifications
You must be signed in to change notification settings - Fork 568
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
Support all struct types for JSON encoding #2824
Conversation
Cc @oldergod for kotlin changes, I mostly focus on the SwiftGenerator. as a nit maybe remove WIP from commit message? |
Thank you for the contribution! |
Thank you! Two things:
|
6d94607
to
900759c
Compare
Addressed feedback above |
| "struct": {"key1":"value1"} | ||
|} | ||
""".trimMargin() | ||
assertJsonEquals(gson.toJson(value), json) |
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.
does this test fail without your change? Just verifying!
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.
The test wasn't properly testing out the constructor creation which I just fixed. To your question, yes it does. Here is the issue:
java.util.NoSuchElementException: ArrayDeque is empty.
at kotlin.collections.ArrayDeque.removeFirst(ArrayDeque.kt:145)
at com.squareup.wire.KotlinConstructorBuilder.build(KotlinConstructorBuilder.kt:114)
at com.squareup.wire.MessageTypeAdapter.read(MessageTypeAdapter.kt:77)
at com.squareup.wire.MessageTypeAdapter.read(MessageTypeAdapter.kt:25)
at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:204)
^ This is due to the custom re-ordering we were doing pre this PR
900759c
to
91dae9c
Compare
I don't think the jvm17 check failure is related to my PR. |
Thanks a lot |
@oldergod Thanks a lot for merging this PR. What timeline shall we expect for the next version of wire including this? |
It's on 4.9.7 |
The current implementation of
KotlinConstructorBuilder.kt
for constructor parameters order implemented here and here makes an inference that is incorrect:repeated
fields andisMap
fields are not the only proto types that are represented as aList
orMap
kotlin types.google.protobuf.Struct
,google.protobuf.ListValue
are also represented asList
andMap
kotlin types making the current mapping incorrect. This lead to the following exception:This PR fixes this by just removing the extra logic for parameter ordering since this commit fixed the issue by correctly ordering constructor parameters.
cc @dnkoutso