I posted a question regarding `GSON` on Stack Over...
# serialization
r
I posted a question regarding
GSON
on Stack Overflow and received this response:
GSON is outdated and in maintenance mode for couple of years already. Main issue with it is that it's entirely reflection based so performance is poor and it sometimes causes weird behaviour like forcefully spawning classes without invoking their constructors. Other one is it has completely no support for Kotlin so it does not recognize or respect metadata like nullability and default values which is really problematic. E.g. with data classes (which are ideal for mapping values to) you can end up with non-nullable property that holds a null value and crashes your program when accessed.
Is this true? Apologies if this is the wrong Slack channel to ask this question... Here's my post (along with the comment): https://stackoverflow.com/questions/78639145/json-syntax-exception-when-parsing-string-containing-json-array-using-typetoken?noredirect=1#com[…]9145
r
In response to your comment to that comment, the preferred JSON deserialization library for Kotlin would be kotlinx serialization 🙂 https://github.com/Kotlin/kotlinx.serialization/tree/master
👍 1
Second to that I'd recommend Jackson
g
I agree with the SO comment, libraries using reflection usually doesn't call init block and don't care about nullability, so instead of having a deserialization issue you'll end up with a runtime NPE in a random place where you use a (supposedly) non-null field. (Kotlin cannot ensure nullability when using reflection for spawning instances.)
r
The GSON readme confirms the poster's comment in the first few lines: https://github.com/google/gson. BTW, you are in the Slack channel for kotlinx.serialization which is generally what you want for Kotlin!
e
my order of preferences would also be kotlinx.serialization first, then if that doesn't suit your needs then either Jackson or moshi. Gson has been in maintenance mode for years
1