-
Notifications
You must be signed in to change notification settings - Fork 525
Kotlin support #55
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
I am not familiar with kotlin Contribution is welcomed. |
Hi @taowen thanks for the speedy response. Today is the first time I've played with annotation processing in Kotlin or Java and the first time I've had to use JSONIter's extension functionality so I can't make a contribution.... However, I have made a Gist of code that works for the specific use case in this issue and posted it here: https://gist.github.com/emrul/2d446eff2084313fcb332f07e62b2ae8 I am able to use this, I hope it may help someone else in future. Thanks again for this wonderful library. |
Your implementation looks fine. Since it contains reference to kotlin, it makes sense to keep it as an extension. You may open a pull request, like https://github.com/json-iterator/java/blob/master/src/main/java/com/jsoniter/annotation/JacksonAnnotationSupport.java |
I checked on the implementation and worked fine for me as well. Thanks for the post here. |
Just a small note: You can get the Missing this out is pretty much the same as applying the annotation to the variables in the constructor, instead of the fields themselves. See this link from the official Kotlin Language Website for more info. Besides that, for my own personal usage Jsoniter (0.9.23) supports Kotlin perfectly except for Note: I am using Dynamic Code Generation here, not Static or Reflection. Update: Boolean values work except when the variable name starts with |
Hi, I'm wondering if there's any plan to support Kotlin code (similarly to how https://github.com/FasterXML/jackson-module-kotlin/blob/master/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt does it)
Specifically: if I have a data class:
Then the annotation is ignored (I believe because of how the Kotlin compiler generates related bytecode) and serializing an instance of this class will result in a JSON object with the key 'name' instead of 'userName'.
However, the following code behaves as expected:
The text was updated successfully, but these errors were encountered: