title: How to use the data type java.util.UUID in Moshi?
body: <p>I used the data type java.util.UUID in my data models and I have used Moshi for serialization.
  But I encountered an error saying that &quot;Platform class java.util.UUID requires explicit JsonAdapter to be registered&quot;</p>
  <p>I have gone through the documentation of Moshi for writing custom adapters and I tried to replicate it accordingly.
  I wrote an adapter and added it to a moshi instance. But still I encounter the same error .</p>
  <p>Adapter</p>
  <pre><code>class UUIDAdapter {
      @ToJson
      fun toJson(value:java.util.UUID):java.util.UUID{
          return value
      }
      @FromJson
      fun fromJson(value: String):java.util.UUID{
          return java.util.UUID.fromString(value)
      }
  }
  </code></pre>
  <p>Model</p>
  <pre><code>@JsonClass(generateAdapter = true)
  data class AddWorkspace(
      @Json(name = &quot;user_id&quot;)
      val user_id: UUID,
      @Json(name = &quot;name&quot;)
      val name:String,
      @Json(name = &quot;descp&quot;)
      val descp:String,
      @Json(name = &quot;created_at&quot;)
      val created_at:String
  )
  </code></pre>
  <p>Moshi</p>
  <pre><code>private val moshi = Moshi.Builder()
          .add(UUIDAdapter())
          .build()
  
      private val retrofitBuilder = Retrofit.Builder()
          .baseUrl(baseUrl)
          .addConverterFactory(MoshiConverterFactory.create(moshi))
  </code></pre>
  <p>What else am I missing so that I can use the adapter correctly ?</p>
  <p>Edit : Well, the methods <code>toJson</code> and <code>fromJson</code> are not being called in the first place. I tried to implement the <code>JsonAdapter</code> class and override the methods <code>toJson</code> and <code>fromJson</code>, but the issue I face here is that in case of the method <code>toJson</code>, I need to send a java.util.UUID value, but the JsonWriter cannot write a value of such data type.
  Please suggest me a way to work my way through this. Thanks :)</p>
  <p>UUID adapter</p>
  <pre><code>class UUIDAdapter:JsonAdapter&lt;UUID&gt;(){
      @FromJson
      override fun fromJson(reader: JsonReader): UUID? {
          return UUID.fromString(reader.readJsonValue().toString())
      }
  
      @ToJson
      override fun toJson(writer: JsonWriter, value: UUID?) {
          writer.jsonValue(value)
      }
  }
  </code></pre>