{"id":427257,"date":"2024-07-25T21:14:27","date_gmt":"2024-07-25T21:14:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=427257"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=427257","title":{"rendered":"<span>\u041a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0432 Kotlin. \u0427\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441 \u0432\u0430\u043c\u0438 \u041c\u0430\u043a\u0441\u0438\u043c \u041a\u0440\u0443\u0433\u043b\u0438\u043a\u043e\u0432 \u0438\u0437 Surf Android Team, \u0438 \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u044e \u043e\u0431 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445 \u0432 Kotlin, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 <a href=\"https:\/\/github.com\/square\/moshi\">Moshi<\/a> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u0438 lint. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 <a href=\"https:\/\/habr.com\/ru\/companies\/surfstudio\/articles\/823906\/\">\u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438<\/a> \u043e\u0431 \u044d\u0442\u0438\u0445 \u0442\u0440\u0451\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u0445 \u2014 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0451.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Moshi<\/h3>\n<p>Moshi \u2014 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 JSON \u0432\/\u0438\u0437 Java \u0438\u043b\u0438 Kotlin-\u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0435\u0451 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, API \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0442\u0430\u043a \u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">implementation(\u201ccom.squareup.moshi:moshi-kotlin:1.15.0\u201d)<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 JSON \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 BookModel:<\/p>\n<pre><code class=\"kotlin\">data class BookModel(  val title: String,  @Json(name = \"page_count\") val pageCount: Int,  val genre: Genre, ) {  enum class Genre {    FICTION,    NONFICTION,  } }  private val moshi = Moshi.Builder().build() private val adapter = moshi.adapter&lt;BookModel&gt;()   private val bookString = \"\"\" {   \"title\": \"Our Share of Night\",   \"page_count\": 588,   \"genre\": \"FICTION\" } \"\"\"   val book = adapter.fromJson(bookString)<\/code><\/pre>\n<p>Moshi \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432\/\u0438\u0437 JSON. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@Json<\/code> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c name \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c page_count \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 JSON, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f pageCount.<\/p>\n<p>Moshi \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432. \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u2014 \u044d\u0442\u043e \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 JSON \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 JSON \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0438\u043f. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 Moshi \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 Java, \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432, \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0438 \u0441\u0442\u0440\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0438\u0445 \u043f\u043e\u043b\u0435 \u0437\u0430 \u043f\u043e\u043b\u0435\u043c.<\/p>\n<p>Moshi \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u043b\u0438\u0431\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u043b\u0438\u0431\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0431\u0430 \u0441\u043b\u0443\u0447\u0430\u044f.<\/p>\n<h4>Moshi \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u043e\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b Moshi \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u043b\u0430\u0441\u0441\u044b-\u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 <code>kapt(\u201ccom.squareup.moshi:moshi-kotlin-codegen:1.15.0\u201d)<\/code> \u0434\u043b\u044f kapt, \u0438\u043b\u0438 <code>ksp(\u201ccom.squareup.moshi:moshi-kotlin-codegen:1.15.0\u201d)<\/code> \u0434\u043b\u044f ksp.<\/p>\n<p>Moshi \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u043f\u043e\u043c\u0435\u0442\u043a\u043e\u0439 <code>@JsonClass (generateAdapter = true)<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0433\u043e:<\/p>\n<pre><code class=\"kotlin\">@JsonClass(generateAdapter = true) data class BookModel(  val title: String,  @Json(name = \"page_count\") val pageCount: Int,  val genre: Genre, ) { ... }<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043e, Moshi \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b <code>BookModelJsonAdapter<\/code> \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <code>\/build\/generated\/source\/kapt\/<\/code>. \u0412\u0441\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 JsonAdapter \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>toString()<\/code>, <code>fromJSON()<\/code> \u0438 <code>toJSON()<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c.<\/p>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435:<\/p>\n<pre><code class=\"kotlin\">private val adapter = moshi.adapter&lt;BookModel&gt;()<\/code><\/pre>\n<p><code>Moshi.adapter()<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 BookModelJsonAdapter.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 Moshi \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <code>AdapterGenerator<\/code>. <code>AdapterGenerator<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/square.github.io\/kotlinpoet\/1.x\/kotlinpoet\/index.html\">KotlinPoet<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>FileSpec<\/code> \u0441 \u043d\u043e\u0432\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c-\u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c.<\/p>\n<p><strong>Kapt<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0432 kapt \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 AbstractProcessor. \u041a\u0430\u043a Moshi \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 JsonClassCodegenProcessor \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <a class=\"mention\" href=\"\/users\/JsonClass\">@JsonClass<\/a>?<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 <code>@Json<\/code>, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b Moshi. <\/p>\n<pre><code class=\"kotlin\">@AutoService(Processor::class) \/\/ 1 public class JsonClassCodegenProcessor : AbstractProcessor() {  ...  private val annotation = JsonClass::class.java  ...  \/\/ 2  override fun getSupportedAnnotationTypes(): Set&lt;String&gt; = setOf(annotation.canonicalName)  ...  override fun process(annotations: Set&lt;TypeElement&gt;, roundEnv: RoundEnvironment): Boolean {    ...    \/\/ 3    for (type in roundEnv.getElementsAnnotatedWith(annotation)) {      ...      val jsonClass = type.getAnnotation(annotation) \/\/ 3a       \/\/ 3b      if (jsonClass.generateAdapter &amp;&amp; jsonClass.generator.isEmpty()) {        \/\/ 3c        val generator = adapterGenerator(type, cachedClassInspector) ?: continue        val preparedAdapter = generator          .prepare(generateProguardRules) { \u2026 }          .addOriginatingElement(type)          .build()        preparedAdapter.spec.writeTo(filer) \/\/ 3d        preparedAdapter.proguardConfig?.writeTo(filer, type) \/\/ 3e    }    return false \/\/ 4  } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>@Autoservice<\/code> \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 <code>JsonClassCodeGenProcessor<\/code> \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>getSupportedAnnotationTypes()<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 <code>@JsonClass<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>process()<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c <code>TypeElements<\/code>, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c <code>@JsonClass<\/code>, \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <code>JsonClass<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f <code>generateAdapter<\/code> \u0438 generator \u0438\u0437 <code>JsonClass<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c <code>AdapterGenerator<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>FileSpec<\/code>, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>AdapterGenerator<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Filer<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <code>Proguard<\/code>, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e <code>AdapterGenerator<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Filer<\/code>.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u0412\u0435\u0440\u043d\u0443\u0442\u044c <code>false<\/code> \u0432 \u043a\u043e\u043d\u0446\u0435 <code>process()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043d\u0430\u0431\u043e\u0440 <code>TypeElements<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0432 \u043d\u0435\u0433\u043e. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 Moshi.<\/p>\n<h4>KSP<\/h4>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0432 KSP \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 <code>SymbolProcessor<\/code>. \u0414\u043b\u044f KSP \u0442\u0430\u043a\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <code>SymbolProcessorProvider<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>SymbolProcessor<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a <code>JsonClassSymbolProcessorProvider<\/code> \u043e\u0442 Moshi \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <code>@JsonClass<\/code> .<\/p>\n<pre><code class=\"kotlin\">@AutoService(SymbolProcessorProvider::class) \/\/ 1 public class JsonClassSymbolProcessorProvider : SymbolProcessorProvider {  override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {    return JsonClassSymbolProcessor(environment) \/\/ 2  } }  private class JsonClassSymbolProcessor(  environment: SymbolProcessorEnvironment, ) : SymbolProcessor {   private companion object {    val JSON_CLASS_NAME = JsonClass::class.qualifiedName!!  }  ...  override fun process(resolver: Resolver): List&lt;KSAnnotated&gt; {    \/\/ 3    for (type in resolver.getSymbolsWithAnnotation(JSON_CLASS_NAME)) {      ...      \/\/ 3a      val jsonClassAnnotation = type.findAnnotationWithType&lt;JsonClass&gt;() ?: continue      val generator = jsonClassAnnotation.generator       \/\/ 3b      if (generator.isNotEmpty()) continue      if (!jsonClassAnnotation.generateAdapter) continue       try {        val originatingFile = type.containingFile!!        val adapterGenerator = adapterGenerator(logger, resolver, type) ?: return emptyList()\/\/ create an AdapterGenerator for the current type        \/\/ 3c        val preparedAdapter = adapterGenerator          .prepare(generateProguardRules) { spec -&gt;            spec.toBuilder()              .addOriginatingKSFile(originatingFile)              .build()          }        \/\/ 3d        preparedAdapter.spec.writeTo(codeGenerator, aggregating = false)        \/\/ 3e        preparedAdapter.proguardConfig?.writeTo(codeGenerator, originatingFile)      } catch (e: Exception) {        logger.error(...)      }    }    return emptyList() \/\/ 4  } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>@Autoservice<\/code> \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 <code>JsonClassSymbolProcessorProvider<\/code>\u00a0 \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>JsonClassSymbolProcessorProvider.create()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>JsonClassSymbolProcessor<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>process()<\/code> \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0432\u0441\u0435\u043c <code>KsAnnotated<\/code> \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>@JsonClass<\/code>, \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <code>JsonClass<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f <code>generateAdapter<\/code> \u0438 <code>generator<\/code> \u0438\u0437 <code>JsonClass<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c <code>AdapterGenerator<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>FileSpec<\/code>, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>AdapterGenerator<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CodeGenerator<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e <code>AdapterGenerator<\/code> \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e Proguard \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CodeGenerator<\/code>.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u0412\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043a\u043e\u043d\u0446\u0435 <code>process()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0437\u0434\u043d\u0438\u0435 \u0440\u0430\u0443\u043d\u0434\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>Moshi \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Json \u0432 \u0444\u0430\u0439\u043b\u0435 incremental.annotation.processors, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 <a href=\"https:\/\/kotlinlang.org\/docs\/ksp-incremental.html\">\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439<\/a>.<\/p>\n<p><code>JsonClassCodegenProcessor<\/code> \u0438 <code>JsonClassCodegenProcessor<\/code> \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0438 \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c\u0438: \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0431\u0435\u0437 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u0434\u0430. \u0410 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u043c \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e API <code>AdapterGenerator<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 KSP \u0432 Moshi \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u043e\u0441\u043e\u0431\u044b\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439. \u0428\u0430\u0433\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0431\u044b\u043b\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b.<\/p>\n<p><strong>Moshi \u0441 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0435\u0439<\/strong><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435 JSON \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"kotlin\">implementation(\u201ccom.squareup.moshi:moshi-kotlin:1.15.0\u201d)<\/code><\/pre>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c <code>BookModel<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>@JsonClass<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>KotlinJsonAdapterFactory<\/code> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 Moshi. <\/p>\n<p><code>KotlinJsonAdapterFactory<\/code> \u2014 \u044d\u0442\u043e \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u043e\u0431\u0449\u0435\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <code>JsonAdapter<\/code> \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Kotlin.<\/p>\n<pre><code class=\"kotlin\">private val moshi = Moshi.Builder()   .add(KotlinJsonAdapterFactory())   .build()<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>Moshi.adapter()<\/code>, \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f <code>BookModel<\/code>, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>KotlinJsonAdapterFactory<\/code>:<\/p>\n<pre><code class=\"kotlin\">private val adapter = moshi.adapter&lt;BookModel&gt;()<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>Moshi.adapter&lt;T&gt;()<\/code> \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 T. Moshi \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u043c\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432 (int, float \u0438 \u0434\u0440\u0443\u0433\u0438\u0445) \u0438 enum, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>MoshiBuilder().add()<\/code>. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>KotlinJsonAdapterFactory<\/code> \u2014 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430.<\/p>\n<p>\u0412\u043e\u0442, \u043a\u0430\u043a <code>KotlinJsonAdapterFactory<\/code> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@Json<\/code> \u0438 \u0435\u0435 \u043f\u043e\u043b\u0435 <code>jsonName<\/code>.<\/p>\n<pre><code class=\"kotlin\">public class KotlinJsonAdapterFactory : JsonAdapter.Factory {  override fun create(type: Type, annotations: Set&lt;Annotation&gt;, moshi: Moshi): JsonAdapter&lt;*&gt;? {   val rawType = type.rawType   val rawTypeKotlin = rawType.kotlin   val parametersByName = constructor.parameters.associateBy { it.name }   try {     val generatedAdapter = moshi.generatedAdapter(type, rawType) \/\/ 1     if (generatedAdapter != null) {       return generatedAdapter     }   } catch (e: RuntimeException) {     if (e.cause !is ClassNotFoundException) {       throw e     }   }   \/\/ 2   val bindingsByName = LinkedHashMap&lt;String, KotlinJsonAdapter.Binding&lt;Any, Any?&gt;&gt;()     for (property in rawTypeKotlin.memberProperties) { \/\/ 3       val parameter = parametersByName[property.name]        var jsonAnnotation = property.findAnnotation&lt;Json&gt;() \/\/ 3a       ...        \/\/ 3b       val jsonName = jsonAnnotation?.name?.takeUnless { it == Json.UNSET_NAME } ?: property.name       ...       val adapter = moshi.adapter&lt;Any?&gt;(...)        bindingsByName[property.name] = KotlinJsonAdapter.Binding(         jsonName, \/\/ 3c         adapter,         property as KProperty1&lt;Any, Any?&gt;,         parameter,         parameter?.index ?: -1,      )    }     val bindings = ArrayList&lt;KotlinJsonAdapter.Binding&lt;Any, Any?&gt;?&gt;()     ...    for (bindingByName in bindingsByName) {      bindings += bindingByName.value.copy(propertyIndex = index++)    }     return KotlinJsonAdapter(bindings, \u2026).nullSafe() \/\/ 4  } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Moshi.generatedAdapter()<\/code>. \u0415\u0441\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>bindingsByName<\/code> \u2014 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u0438\u0445 <code>Binding<\/code>\u2019\u0430\u043c\u0438. <code>Binding<\/code> \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u043c\u0435\u043d\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u0439\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@Json<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043e\u043d\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u0437\u0430\u0434\u0430\u0442\u044c <code>jsonName<\/code> \u0432 \u043f\u043e\u043b\u0435 <code>name<\/code> \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>page_count<\/code>) \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044f <code>jsonName<\/code>. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>pageCount<\/code>) \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>jsonName<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>jsonName<\/code> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <code>Binding<\/code>\u2019\u0430 \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u0412\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u043e\u0432\u044b\u0439 <code>KotlinJsonAdapter<\/code> \u0441 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 <code>Binding<\/code>\u2019\u0430\u043c\u0438<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 t<code>oJson()<\/code> \u0438\u043b\u0438 <code>fromJson()<\/code> Moshi \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>jsonName<\/code> \u0438\u0437 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044f JSON.<\/p>\n<h4>Lint-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432 Moshi<\/h4>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 Moshi \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a lint. \u041d\u043e, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 Slack \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u00a0Moshi. \u042d\u0442\u043e \u00ab<a href=\"https:\/\/googlesamples.github.io\/android-custom-lint-rules\/checks\/MoshiUsageArray.md.html\">Prefer List over Array<\/a>\u00bb \u0438 \u00ab<a href=\"https:\/\/googlesamples.github.io\/android-custom-lint-rules\/checks\/MoshiUsagePrivateConstructor.md.html\">Constructors in Moshi classes cannot be private<\/a>\u00bb.<\/p>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 Moshi, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 <code>MoshiUsageDetector<\/code>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0435\u0440\u0435\u0432\u043e\u043c UAST \u0438\u0437 lint API \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u00abPrefer List over Array\u00bb. \u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043e \u043a\u0430\u043a <code>ISSUE_ARRAY<\/code> \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435-\u043a\u043e\u043c\u043f\u0430\u043d\u044c\u043e\u043d\u0435 <code>MoshiUsageDetector<\/code> \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Moshi \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u044b.<\/p>\n<pre><code class=\"kotlin\">class MoshiUsageDetector : Detector(), SourceCodeScanner {   override fun getApplicableUastTypes() = listOf(UClass::class.java) \/\/ 1   override fun createUastHandler(context: JavaContext): UElementHandler { \/\/ 2    return object : UElementHandler() {      override fun visitClass(node: UClass) {        ...        \/\/ 3        val jsonClassAnnotation = node.findAnnotation(FQCN_JSON_CLASS)        if (jsonClassAnnotation == null) return \/\/ 4        ...        val primaryConstructor =          node.constructors            .asSequence()            .mapNotNull { it.getUMethod() }            .firstOrNull { it.sourcePsi is KtPrimaryConstructor }        ...        for (parameter in primaryConstructor.uastParameters) { \/\/ 5          val sourcePsi = parameter.sourcePsi          if (sourcePsi is KtParameter &amp;&amp; sourcePsi.isPropertyParameter()) {            val shouldCheckPropertyType = ...            if (shouldCheckPropertyType) {              \/\/ 5a              checkMoshiType(                context,                parameter.type,                parameter,                parameter.typeReference!!,              ...              )            }          }        }      }    }  }   private fun checkMoshiType(    context: JavaContext,    psiType: PsiType,    parameter: UParameter,    typeNode: UElement,     ...  ) {    if (psiType is PsiPrimitiveType) return    if (psiType is PsiArrayType) { \/\/ 6      ...      context.report(        ISSUE_ARRAY,        context.getLocation(typeNode),        ISSUE_ARRAY.getBriefDescription(TextFormat.TEXT),        quickfixData =          fix()            .replace()            .name(\"Change to $replacement\")            ...            .build()      )      return    }    ... \/\/ 7   }   companion object {    private const val FQCN_JSON_CLASS = \"com.squareup.moshi.JsonClass\"    ...    private val ISSUE_ARRAY =      createIssue(        \"Array\",        \"Prefer List over Array.\",        \"\"\"        Array types are not supported by Moshi, please use a List instead\u2026        \"\"\"        .trimIndent(),        Severity.WARNING,      )    ...  } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>getApplicableUastTypes()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>UClass<\/code> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u0442\u0435\u043a\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435.<\/p>\n<\/li>\n<li>\n<p><code>createUastHandler()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>UElementHandler<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u043a\u043b\u0430\u0441\u0441\u0430. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 <code>visitClass()<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0439\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@JsonClass<\/code> \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c return, \u0435\u0441\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0443\u0437\u043b\u0430 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0437\u0432\u0430\u0442\u044c <code>checkMoshiType()<\/code> \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u0412 <code>checkMoshiType()<\/code> \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 report, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u2014 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>checkMoshiType()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u2014 \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0448\u0430\u0433\u0443 4, \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>@JsonClass<\/code>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e <code>MoshiUsageDetector<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f Moshi \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.<\/p>\n<h4>#\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u044b. \u041a\u043e\u0434\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043e\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u043a\u043e\u0434\u0430 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0438\u043b\u0438 lint-\u043f\u0440\u0430\u0432\u0438\u043b \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043d\u0435 \u0442\u0430\u043a\u0438\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c. <\/p>\n<p>\u041d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u043e\u0442\u0438\u0432\u0438\u0440\u0443\u044e\u0442 \u0432\u0430\u0441 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043d\u0435 \u0431\u043e\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438.<\/p>\n<blockquote>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043f\u0440\u043e Android \u2014 \u0432 Telegram-\u043a\u0430\u043d\u0430\u043b\u0435 Surf Android Team.\u00a0<\/p>\n<p>\u041a\u0435\u0439\u0441\u044b, \u043b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0438 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 Android Surf \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.\u00a0<a href=\"https:\/\/t.me\/surf_android\"><strong>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c<\/strong><\/a>!<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/828500\/\"> https:\/\/habr.com\/ru\/articles\/828500\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441 \u0432\u0430\u043c\u0438 \u041c\u0430\u043a\u0441\u0438\u043c \u041a\u0440\u0443\u0433\u043b\u0438\u043a\u043e\u0432 \u0438\u0437 Surf Android Team, \u0438 \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u044e \u043e\u0431 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445 \u0432 Kotlin, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 <a href=\"https:\/\/github.com\/square\/moshi\">Moshi<\/a> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u0438 lint. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 <a href=\"https:\/\/habr.com\/ru\/companies\/surfstudio\/articles\/823906\/\">\u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438<\/a> \u043e\u0431 \u044d\u0442\u0438\u0445 \u0442\u0440\u0451\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u0445 \u2014 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0451.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Moshi<\/h3>\n<p>Moshi \u2014 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 JSON \u0432\/\u0438\u0437 Java \u0438\u043b\u0438 Kotlin-\u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0435\u0451 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, API \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0442\u0430\u043a \u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">implementation(\u201ccom.squareup.moshi:moshi-kotlin:1.15.0\u201d)<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 JSON \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 BookModel:<\/p>\n<pre><code class=\"kotlin\">data class BookModel(  val title: String,  @Json(name = \"page_count\") val pageCount: Int,  val genre: Genre, ) {  enum class Genre {    FICTION,    NONFICTION,  } }  private val moshi = Moshi.Builder().build() private val adapter = moshi.adapter&lt;BookModel&gt;()   private val bookString = \"\"\" {   \"title\": \"Our Share of Night\",   \"page_count\": 588,   \"genre\": \"FICTION\" } \"\"\"   val book = adapter.fromJson(bookString)<\/code><\/pre>\n<p>Moshi \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432\/\u0438\u0437 JSON. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@Json<\/code> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c name \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c page_count \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 JSON, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f pageCount.<\/p>\n<p>Moshi \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432. \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u2014 \u044d\u0442\u043e \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 JSON \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 JSON \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0438\u043f. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443 Moshi \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 Java, \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432, \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0438 \u0441\u0442\u0440\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0438\u0445 \u043f\u043e\u043b\u0435 \u0437\u0430 \u043f\u043e\u043b\u0435\u043c.<\/p>\n<p>Moshi \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u043b\u0438\u0431\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u043b\u0438\u0431\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0431\u0430 \u0441\u043b\u0443\u0447\u0430\u044f.<\/p>\n<h4>Moshi \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u043e\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b Moshi \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u043b\u0430\u0441\u0441\u044b-\u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 <code>kapt(\u201ccom.squareup.moshi:moshi-kotlin-codegen:1.15.0\u201d)<\/code> \u0434\u043b\u044f kapt, \u0438\u043b\u0438 <code>ksp(\u201ccom.squareup.moshi:moshi-kotlin-codegen:1.15.0\u201d)<\/code> \u0434\u043b\u044f ksp.<\/p>\n<p>Moshi \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u043f\u043e\u043c\u0435\u0442\u043a\u043e\u0439 <code>@JsonClass (generateAdapter = true)<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0433\u043e:<\/p>\n<pre><code class=\"kotlin\">@JsonClass(generateAdapter = true) data class BookModel(  val title: String,  @Json(name = \"page_count\") val pageCount: Int,  val genre: Genre, ) { ... }<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043e, Moshi \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b <code>BookModelJsonAdapter<\/code> \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <code>\/build\/generated\/source\/kapt\/<\/code>. \u0412\u0441\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 JsonAdapter \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>toString()<\/code>, <code>fromJSON()<\/code> \u0438 <code>toJSON()<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c.<\/p>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435:<\/p>\n<pre><code class=\"kotlin\">private val adapter = moshi.adapter&lt;BookModel&gt;()<\/code><\/pre>\n<p><code>Moshi.adapter()<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 BookModelJsonAdapter.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 Moshi \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <code>AdapterGenerator<\/code>. <code>AdapterGenerator<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/square.github.io\/kotlinpoet\/1.x\/kotlinpoet\/index.html\">KotlinPoet<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>FileSpec<\/code> \u0441 \u043d\u043e\u0432\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c-\u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c.<\/p>\n<p><strong>Kapt<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0432 kapt \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 AbstractProcessor. \u041a\u0430\u043a Moshi \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 JsonClassCodegenProcessor \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <a class=\"mention\" href=\"\/users\/JsonClass\">@JsonClass<\/a>?<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 <code>@Json<\/code>, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b Moshi. <\/p>\n<pre><code class=\"kotlin\">@AutoService(Processor::class) \/\/ 1 public class JsonClassCodegenProcessor : AbstractProcessor() {  ...  private val annotation = JsonClass::class.java  ...  \/\/ 2  override fun getSupportedAnnotationTypes(): Set&lt;String&gt; = setOf(annotation.canonicalName)  ...  override fun process(annotations: Set&lt;TypeElement&gt;, roundEnv: RoundEnvironment): Boolean {    ...    \/\/ 3    for (type in roundEnv.getElementsAnnotatedWith(annotation)) {      ...      val jsonClass = type.getAnnotation(annotation) \/\/ 3a       \/\/ 3b      if (jsonClass.generateAdapter &amp;&amp; jsonClass.generator.isEmpty()) {        \/\/ 3c        val generator = adapterGenerator(type, cachedClassInspector) ?: continue        val preparedAdapter = generator          .prepare(generateProguardRules) { \u2026 }          .addOriginatingElement(type)          .build()        preparedAdapter.spec.writeTo(filer) \/\/ 3d        preparedAdapter.proguardConfig?.writeTo(filer, type) \/\/ 3e    }    return false \/\/ 4  } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>@Autoservice<\/code> \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 <code>JsonClassCodeGenProcessor<\/code> \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>getSupportedAnnotationTypes()<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 <code>@JsonClass<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>process()<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c <code>TypeElements<\/code>, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c <code>@JsonClass<\/code>, \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <code>JsonClass<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f <code>generateAdapter<\/code> \u0438 generator \u0438\u0437 <code>JsonClass<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c <code>AdapterGenerator<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>FileSpec<\/code>, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>AdapterGenerator<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Filer<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <code>Proguard<\/code>, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e <code>AdapterGenerator<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Filer<\/code>.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u0412\u0435\u0440\u043d\u0443\u0442\u044c <code>false<\/code> \u0432 \u043a\u043e\u043d\u0446\u0435 <code>process()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043d\u0430\u0431\u043e\u0440 <code>TypeElements<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0432 \u043d\u0435\u0433\u043e. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 Moshi.<\/p>\n<h4>KSP<\/h4>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0432 KSP \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 <code>SymbolProcessor<\/code>. \u0414\u043b\u044f KSP \u0442\u0430\u043a\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <code>SymbolProcessorProvider<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>SymbolProcessor<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a <code>JsonClassSymbolProcessorProvider<\/code> \u043e\u0442 Moshi \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <code>@JsonClass<\/code> .<\/p>\n<pre><code class=\"kotlin\">@AutoService(SymbolProcessorProvider::class) \/\/ 1 public class JsonClassSymbolProcessorProvider : SymbolProcessorProvider {  override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {    return JsonClassSymbolProcessor(environment) \/\/ 2  } }  private class JsonClassSymbolProcessor(  environment: SymbolProcessorEnvironment, ) : SymbolProcessor {   private companion object {    val JSON_CLASS_NAME = JsonClass::class.qualifiedName!!  }  ...  override fun process(resolver: Resolver): List&lt;KSAnnotated&gt; {    \/\/ 3    for (type in resolver.getSymbolsWithAnnotation(JSON_CLASS_NAME)) {      ...      \/\/ 3a      val jsonClassAnnotation = type.findAnnotationWithType&lt;JsonClass&gt;() ?: continue      val generator = jsonClassAnnotation.generator       \/\/ 3b      if (generator.isNotEmpty()) continue      if (!jsonClassAnnotation.generateAdapter) continue       try {        val originatingFile = type.containingFile!!        val adapterGenerator = adapterGenerator(logger, resolver, type) ?: return emptyList()\/\/ create an AdapterGenerator for the current type        \/\/ 3c        val preparedAdapter = adapterGenerator          .prepare(generateProguardRules) { spec -&gt;            spec.toBuilder()              .addOriginatingKSFile(originatingFile)              .build()          }        \/\/ 3d        preparedAdapter.spec.writeTo(codeGenerator, aggregating = false)        \/\/ 3e        preparedAdapter.proguardConfig?.writeTo(codeGenerator, originatingFile)      } catch (e: Exception) {        logger.error(...)      }    }    return emptyList() \/\/ 4  } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>@Autoservice<\/code> \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 <code>JsonClassSymbolProcessorProvider<\/code>\u00a0 \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>JsonClassSymbolProcessorProvider.create()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>JsonClassSymbolProcessor<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>process()<\/code> \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0432\u0441\u0435\u043c <code>KsAnnotated<\/code> \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>@JsonClass<\/code>, \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <code>JsonClass<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f <code>generateAdapter<\/code> \u0438 <code>generator<\/code> \u0438\u0437 <code>JsonClass<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c <code>AdapterGenerator<\/code> \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>FileSpec<\/code>, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>AdapterGenerator<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CodeGenerator<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e <code>AdapterGenerator<\/code> \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e Proguard \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CodeGenerator<\/code>.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u0412\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043a\u043e\u043d\u0446\u0435 <code>process()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0437\u0434\u043d\u0438\u0435 \u0440\u0430\u0443\u043d\u0434\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>Moshi \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Json \u0432 \u0444\u0430\u0439\u043b\u0435 incremental.annotation.processors, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 <a href=\"https:\/\/kotlinlang.org\/docs\/ksp-incremental.html\">\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439<\/a>.<\/p>\n<p><code>JsonClassCodegenProcessor<\/code> \u0438 <code>JsonClassCodegenProcessor<\/code> \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0438 \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c\u0438: \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0431\u0435\u0437 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u0434\u0430. \u0410 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u043c \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e API <code>AdapterGenerator<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 KSP \u0432 Moshi \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u043e\u0441\u043e\u0431\u044b\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439. \u0428\u0430\u0433\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0431\u044b\u043b\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b.<\/p>\n<p><strong>Moshi \u0441 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0435\u0439<\/strong><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435 JSON \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"kotlin\">implementation(\u201ccom.squareup.moshi:moshi-kotlin:1.15.0\u201d)<\/code><\/pre>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c <code>BookModel<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>@JsonClass<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>KotlinJsonAdapterFactory<\/code> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 Moshi. <\/p>\n<p><code>KotlinJsonAdapterFactory<\/code> \u2014 \u044d\u0442\u043e \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u043e\u0431\u0449\u0435\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <code>JsonAdapter<\/code> \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Kotlin.<\/p>\n<pre><code class=\"kotlin\">private val moshi = Moshi.Builder()   .add(KotlinJsonAdapterFactory())   .build()<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>Moshi.adapter()<\/code>, \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f <code>BookModel<\/code>, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>KotlinJsonAdapterFactory<\/code>:<\/p>\n<pre><code class=\"kotlin\">private val adapter = moshi.adapter&lt;BookModel&gt;()<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>Moshi.adapter&lt;T&gt;()<\/code> \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 T. Moshi \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u043c\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432 (int, float \u0438 \u0434\u0440\u0443\u0433\u0438\u0445) \u0438 enum, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>MoshiBuilder().add()<\/code>. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>KotlinJsonAdapterFactory<\/code> \u2014 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430.<\/p>\n<p>\u0412\u043e\u0442, \u043a\u0430\u043a <code>KotlinJsonAdapterFactory<\/code> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@Json<\/code> \u0438 \u0435\u0435 \u043f\u043e\u043b\u0435 <code>jsonName<\/code>.<\/p>\n<pre><code class=\"kotlin\">public class KotlinJsonAdapterFactory : JsonAdapter.Factory {  override fun create(type: Type, annotations: Set&lt;Annotation&gt;, moshi: Moshi): JsonAdapter&lt;*&gt;? {<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-427257","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427257"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427257\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}