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?
08/03/2022, 9:16 PM
I'd suggest kotlinx serialization or Moshi, not Gson
08/03/2022, 9:21 PM
kotlinx.serialization has worked well for me so far. It’s also multiplatform if you ever decide to go that route.
08/03/2022, 9:30 PM
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.