I'm learning Android development, trying to do cod...
# getting-started
r
I'm learning Android development, trying to do code a simple app. Want to load a JSON file on the assets folder into a string in ViewModel (livedata). Can someone point correct way to load the JSON data (user, id:Int + name:String), shall i use GSON (looks its "old), Moshi (newer) or something else?
j
I'd suggest kotlinx serialization or Moshi, not Gson
👍 2
l
kotlinx.serialization has worked well for me so far. It’s also multiplatform if you ever decide to go that route.
a
The main reason you might want to avoid Gson -- in kotlin specifically -- is that it isn't null safe. It will happily put a null in your non-null properties, which will crash as soon as you try to access them.