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

Pure Kotlin implementation and dependencies #1

Open
remysanfeliu opened this issue Oct 31, 2018 · 3 comments
Open

Pure Kotlin implementation and dependencies #1

remysanfeliu opened this issue Oct 31, 2018 · 3 comments

Comments

@remysanfeliu
Copy link

Hi ! Love your syntax and the way the code looks :) Great job !
I'm working on a multiplatform Kotlin project though, and thus can't rely on org.json as it's written for java. It would be great if you could get rid of this dependency to be actually fully Kotlin based !

Just a suggestion for future releases !

@remysanfeliu remysanfeliu changed the title Pure Kotlin implementation Pure Kotlin implementation and dependencies Oct 31, 2018
@s4cha
Copy link
Member

s4cha commented Nov 1, 2018

Hi @remysanfeliu, thanks for the kind words!
Actually I am quite new to the Kotlin ecosystem and have only used it on Android so far.
Could you elaborate one how you'd go about parsing JSON without depending on java libraries?
Thanks a ton :)

@remysanfeliu
Copy link
Author

The idea is to remove any import and dependency on JVM-based libraries ideally, so that the parser is pure Kotlin code, end to end, including deps. org.json is coded with Java, so that's that :D
My suggestion is to use kotlinx.serialization instead to parse the JSON, which is guaranteed to support Kotlin multiplatform. Although, it might be a difficult task because it only seems to be supporting parsing via annotations, and not "manual" browsing which might be useful for your lib (don't know, actually). BTW, don't turn to Klaxon, it's actually based on some java.Class here and there to match types, so, it seems that it couldn't fit a multiplatform project =/ (I need to check this though, will be back in a few days with a confirmation)

@s4cha
Copy link
Member

s4cha commented Nov 6, 2018

@remysanfeliu Thanks for your answer.
We deliberately don't want to use annotations as you pointed out. They pollute the model and in my opinion, they violate the Single Responsibility Principle. (I personally avoid them like the plague xD)
Klaxon is not an option in that sense :)
I agree that being "java free" is a very appealing idea. However, this project is just a helper we did to clean our parsing code and are not willing to spend too much time in such endeavour.
Additionally,kotlinx.serialization seems to be the way to go forward for Kotlin-pure implementations.

Feel free to try on your own of course, and if you have anything cool I'd bee very curious to see the result :)
Cheers,

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

No branches or pull requests

2 participants