Skip to content

Latest commit

 

History

History
103 lines (77 loc) · 2.93 KB

CHANGELOG.md

File metadata and controls

103 lines (77 loc) · 2.93 KB

Changelog

0.4.3

2022-06-07

  • Fix: try-catch field lookups in EnumClassChecker to avoid crashing if the field is missing (such as in minified builds).

Dependency updates

Kotlin 1.5.31
Gson 2.8.9

0.4.2

2021-03-01

  • Fix: interop would always take Moshi or Gson if any ClassChecker supported it, preventing use of short-circuiting custom checkers from pre-empting them. This is now fixed!

0.4.1

2021-02-04

  • Fix: Best-effort preserve the exact encoding of numbers during interop. Some users rely on lenient parsing of numbers as strings, which can lead to problems if interop results in int/long literals being converted to floating-point types (which changes the value of the resulting string!). Slack would totally never rely on this behavior, no way.
  • Update to Kotlin 1.4.30

0.4.0

2020-11-17

  • New: JsonAdapterAnnotationClassChecker in StandardClassCheckers to watch for GSON's @JsonAdapter annotation.
  • Fix: Support JsonTreeWriter in interop. Note that our implementation uses internal GSON APIs to work around this, which obviously isn't ideal. We've PR'd a fix for this upstream google/gson#1819.

0.3.0

2020-11-12

  • New: Builder API for composing logic. This allows for easy customization of picking which classes should go to each serializer.

    val builder = Moshi.Builder().build()
      .interopBuilder(GsonBuilder().create())
    
    builder.addGsonType<String>()
    builder.addMoshiType<Int>()
    builder.addGsonType<List<String>>() // Interesting because only the List is captured
    builder.addGsonFactory(object : TypeAdapterFactory {
      override fun <T : Any?> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
        return if (type.rawType == Boolean::class.javaObjectType) {
          @Suppress("UNCHECKED_CAST")
          gson.getAdapter(Boolean::class.java) as TypeAdapter<T>
        } else {
          null
        }
      }
    })
    builder.addMoshiFactory { type, _, moshi ->
      if (Types.getRawType(type) == Double::class.javaObjectType) {
        moshi.adapter<Double>()
      } else {
        null
      }
    }
  • API Change: MoshiClassChecker is now just ClassChecker and returns a nullable Serializer. Serializer can be MOSHI, GSON, or null to defer to another checker. The builder will try checkers until one claims the given class.

  • New: Instead of indicating interop via Pair<Moshi, Gson>, these are now represented via MoshiGsonInterop data class.

  • New: Optional logger API via the builder for easy printing of the internal decision tree.

  • New: Default serializer option via the builder.

  • New: Public APIs for standard ClassCheckers.

0.2.0

2020-10-22

Add support for lenient and serializeNulls to match behavior between adapters.

Thanks to @romankivalin for contributing to this release.

0.1.0

2020-10-05

Initial release!