Skip to content

Releases: ZacSweers/MoshiX

0.12.0

16 Jul 02:40
c723658
Compare
Choose a tag to compare
  • Update to KSP 1.5.21-1.0.0-beta05.
  • Update to Kotlin 1.5.21.
  • Update to Dokka 1.5.0.
  • Update to KotlinPoet 1.9.0.
  • Test against JDK 17 early access previews.
  • New: moshi-ksp and moshi-sealed's codegen both support a new moshi.generateProguardRules option. This can be
    set to false to disable proguard rule generation.
  • Fix: Artifacts now ship with a -module-name attribute set to their artifact ID to help avoid module name
    collisions.

Thanks to @SeongUgJung and @slmlt for contributing to this release!

0.11.2

31 May 21:05
948677e
Compare
Choose a tag to compare
  • moshi-ksp - Fix a bug where supertypes compiled outside the current compilation weren't recognized as Kotlin types.

0.11.1

27 May 20:59
1056ca3
Compare
Choose a tag to compare
  • Update to KSP 1.5.10-1.0.0-beta01
  • Update to Kotlin 1.5.10

0.11.0

14 May 06:29
d62f644
Compare
Choose a tag to compare

Project-wide

  • Update Kotlin to 1.5.0.
  • Update deprecated Kotlin stdlib usages during 1.5.0 upgrade.
  • Support Java 16.
  • Update KotlinPoet to 1.8.0.
  • Small documentation improvements.

All KSP artifacts

  • Update KSP to 1.5.0-1.0.0-alpha10.
  • Switch to new SymbolProcessorProvider APIs.
  • Adopt new Sequence-based KSP APIs where possible.

All metadata-reflect artifacts

  • Update kotlinx-metadata to 0.3.0.

moshi-ksp

  • Fix: Don't fail on annotations that are typealias'd.
  • Fix: Support enum entry values in copied @JsonQualifier annotations.
  • Fix: Support array values in copied @JsonQualifier annotations.

moshi-sealed

  • Enhancement: sealed interfaces and package-wide sealed classes are fully supported in KSP, kapt, reflect, and metadata-reflect.
  • Fix: Make moshi-adapters an api dependency in moshi-sealed-runtime

moshi-records-reflect

  • RecordsJsonAdapterFactory is no longer in preview and now built against JDK 16.
  • New: A dedicated README page can be found here.
final record Message(String value) {
}

public static void main(String[] args) {
  Moshi moshi = new Moshi.Builder()
    .add(new RecordsJsonAdapterFactory())
    .build();
  
  JsonAdapter<Message> messageAdapter = moshi.adapter(Message.class);
}

moshi-sealed: java-sealed-reflect

  • JavaSealedJsonAdapterFactory is now built against JDK 16. Note this feature is still in preview.
  • New: A dedicated README section can be found here.

Thanks to the following contributors for contributing to this release! @remcomokveld, @martinbonnin, and @eneim

0.9.2

01 Mar 09:15
f6472e3
Compare
Choose a tag to compare
0.9.2 Pre-release
Pre-release

KSP

  • Update KSP to 1.4.30-1.0.0-alpha04 in KSP-using libraries. Among other changes, these processors now run all
    errors through KSP's native KspLogger.error() API now.

moshi-ksp

  • Fix: Support function types as property types.
  • Fix: Support generic arrays when invoking defaults constructors.
  • Some small readability improvements to generated code.

Moshi-sealed

  • Add tests for Kotlin 1.4.30's preview support for sealed interfaces. These won't be officially supported until
    Kotlin 1.5, but they do appear to Just Work™️ since Kotlin reuses the same sealed APIs under the hood.
  • Support Kotlin 1.5's upcoming sealed interfaces in KSP.

0.8.0

27 Jan 06:28
2f7368c
Compare
Choose a tag to compare
0.8.0 Pre-release
Pre-release
  • New: Experimental support for Java record classes via new moshi-records-reflect artifact. See
    RecordsJsonAdapterFactory. Requires JDK 15 + --enable-preview.

    Moshi moshi = new Moshi.Builder()
        .add(new RecordsJsonAdapterFactory())
        .build();
    
    final record Message(String value) {
    }
  • New: Experimental support for Java sealed classes and interfaces in moshi-sealed via new
    moshi-sealed-java-sealed-reflect artifact. See JavaSealedJsonAdapterFactory. Requires JDK 15 + --enable-preview.

    Moshi moshi = new Moshi.Builder()
        .add(new JavaSealedJsonAdapterFactory())
        .add(new RecordsJsonAdapterFactory())
        .build();
    
    @JsonClass(generateAdapter = true, generator = "sealed:type")
    sealed interface MessageInterface
        permits MessageInterface.Success, MessageInterface.Error {
    
      @TypeLabel(label = "success", alternateLabels = {"successful"})
      final record Success(String value) implements MessageInterface {
      }
      
      @TypeLabel(label = "error")
      final record Error(Map<String, Object> error_logs) implements MessageInterface {
      }
    }
  • New: @AdaptedBy annotation support in moshi-adapters. This is analogous to Gson's @JsonAdapter annotation,
    allowing you to annotate a class or a property with it to indicate which JsonAdapter or JsonAdapter.Factory
    should be used to encode it.

 val moshi = Moshi.Builder()
   .add(AdaptedBy.Factory())
   .build()
 
 @AdaptedBy(StringAliasAdapter::class)
 data class StringAlias(val value: String)
 
 class StringAliasAdapter : JsonAdapter<StringAlias>() {
   override fun fromJson(reader: JsonReader): StringAlias? {
     return StringAlias(reader.nextString())
   }
 
   override fun toJson(writer: JsonWriter, value: StringAlias?) {
     if (value == null) {
       writer.nullValue()
       return
     }
     writer.value(value.value)
   }
 }

0.7.1

12 Jan 03:07
a7b96e6
Compare
Choose a tag to compare
0.7.1 Pre-release
Pre-release
  • Update to KSP 1.4.20-dev-experimental-20210111.