Romão
08/03/2022, 9:15 PMval moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
val jsonAdapter: JsonAdapter<User> = moshi.adapter(User::class.java)
val data = AssetManager.open("users.json").bufferedReader().use { it.readText() }
jsonAdapter.fromJson(data)
how to read the User.json in the assets folder into a string? then input the string into jsonAdapter.fromJson(string)?gildor
08/04/2022, 2:27 AMRomão
08/04/2022, 9:19 AMDaniel B Duval
08/04/2022, 4:28 PMopenRawResource
. You’ll find examples online on how to read that out to an input stream.
https://developer.android.com/reference/android/content/res/Resources#openRawResource(int,%20android.util.TypedValue)