![]() ![]() We need to achieve the following objectives: We can write a custom TypeAdapterFactory to complete our support for Kotlin Data Class. The Gson framework can intervene in the Json data parsing process by adding a TypeAdapterFactory. JsonDataException is also thrown if a field is missing from Json and the default value is not set for that field. Moshi validates Json parameters that explicitly return NULL, and throws a JsonDataException if the parameter cannot be null. Let's look at an example where there is no default constructor value data class Bean( val id: Int. ![]() Recently I happened to have some time, and found that this kind of problem appeared in the company's project many times, so I did a research on the cause of this problem, and sort out the treatment plan. I did not study them carefully before, but only dealt with the parameters with problems in order to fix the problem. This year, nullPointerExceptions of Gson and Kotlin Data Class were found online for several times. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |