Skip to content
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

API v14 / New Parser Library / Kotlin #84

Open
dbrgn opened this issue Nov 15, 2020 · 1 comment
Open

API v14 / New Parser Library / Kotlin #84

dbrgn opened this issue Nov 15, 2020 · 1 comment

Comments

@dbrgn
Copy link
Contributor

dbrgn commented Nov 15, 2020

Last week we released v14 of the SpaceAPI schema! https://github.com/SpaceApi/schema/blob/master/MIGRATION.md

To support this, I'd like to rewrite the parser, which is currently using the (horrible!) Android JSON library.

I first took a look at https://app.quicktype.io/ and the generated source code. I like that it's based on Jackson, but it uses some Java 8 standard library functions that are not part of Android API21 and would need to be rewritten.

I thought about simplifying the generated code using plain Jackson calls, but that also seems quite a lot of work.

In the end, I saw that Kotlin has a new serialization framework that makes (de)serialization quite easy. I don't have much Kotlin experience, but it's definitely a nice language!

So TL;DR: Here's a new project I started, that should provide a standalone lenient Kotlin/Java parser for SpaceAPI endpoints. https://github.com/spaceapi-community/spaceapi-kt The goal is to have a single library / wrapper type that can parse both v0.13 and v14 endpoints (and future versions as well). The focus is on parsing, not on serializing, so we can skip a lot of validation logic.

Kotlin has nice Java interop, so Kotlin can call Java and vice versa. The only cost is that the Kotlin runtime needs to be integrated as a Gradle dependency, which makes the app a bit larger. On the other hand we then have the option of using Kotlin as well in the app code.

(Maybe it's also possible to convert the library into pure-JVM bytecode that does not require the Kotlin runtime, but I doubt it.)

@rorist do you see any problem with this approach? Would you accept a PR that replaces the parser with this library?

@dbrgn
Copy link
Contributor Author

dbrgn commented Nov 15, 2020

I tested the deserialization with a local JAR file and it already works 🙂 I plan to publish the spaceapi-kt library on Bintray though, then we can pull it in using Gradle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant