com.squareup.moshi:moshi-kotlin-tests
1.10.0
#571 most downloaded on Maven Central
square/moshi
What this package is like to depend on
Last release 6 years ago
no release in 18 months
Release timing varies
gaps range from 2 weeks to 7 months
Nearly every release is documented
notes for 8 of 8 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
8 releases · first in 2019
0 releases in the last 12 months
see the full history below
Release timeline
8 releases · Jul 2019 to Aug 2020Releases
latest 8-
1.10.027 Aug 2020Release notes
Open source →- New: Upgrade to Kotlin 1.4.0.
- New:
JsonReader.promoteNameToValue()makes it easier to build customMapadapters. - New:
Options.strings(). - New:
PolymorphicJsonAdapterFactory.withFallbackJsonAdapter()makes it possible to handle unrecognized types when encoding and decoding. - New: Add
JsonWriter.jsonValueAPI - New: Code gen now generates precise proguard rules on-the-fly.
- New: Improve error when incorrectly trying to use a collection class like
ArrayListinstead ofList - Fix: Prevent R8 from keeping all
@Metadataannotations - Fix: Avoid VerifyErrors on Android 4.4 devices when using R8
- Fix: Fix resolution of types in superclass settable properties
-
1.9.312 Jun 2020Release notes
Open source →2020-06-11
- Fix: Tweak a shrinker rule to mitigate an R8 bug which was causing classes unrelated to the Kotlin adpater code generation to be retained.
- Fix: Ensure that the Kotlin adapter code generation does not line wrap in the middle of a string if your JSON keys contain spaces.
- Fix: Strip type annotations before emitting type references like
Foo::classin the Kotlin adapter code generation. - Fix: Separate the runtime check for Kotlin's
DefaultConstructorMarkerfrom the check forMetadata. A shrinker may have removedMetadataand we should still check forDefaultConstructorMarker.
-
1.9.218 Nov 2019Release notes
Open source →2019-11-17
- Fix: Generate correct adapters for several special cases including reified inline types, public
classes enclosed in internal classes, deprecated types with
-Werror, primitives in type parameters, nullables in type parameters, and type aliases in type parameters.
- Fix: Generate correct adapters for several special cases including reified inline types, public
classes enclosed in internal classes, deprecated types with
-
1.9.107 Nov 2019Release notes
Open source →2019-10-30
- Fix: "abstract function ... cannot have code" code gen crash when parsing Kotlin metadata.
- Fix: Generate code to support constructors with more than 32 parameters. The 1.9.0 release had a regression where classes with 33+ parameters would crash upon decoding.
- Fix: Generate code to support more constructor cases, such as classes with non-property parameters and classes with multiple constructors.
- Fix: Generate code to handle type aliases in type parameters.
-
1.9.007 Nov 2019Release notes
Open source →2019-10-29
-
This release requires kotlin-reflect or moshi-kotlin-codegen for all Kotlin classes.
Previously Moshi wouldn't differentiate between Kotlin classes and Java classes if Kotlin was not configured. This caused bad runtime behavior such as putting null into non-nullable fields! If you attempt to create an adapter for a Kotlin type, Moshi will throw an
IllegalArgumentException.Fix this with either the reflection adapter:
val moshi = Moshi.Builder() // ... add your own JsonAdapters and factories ... .add(KotlinJsonAdapterFactory()) .build()Or the codegen annotation processor:
@JsonClass(generateAdapter = true) data class BlackjackHand( val hidden_card: Card, val visible_cards: List<Card> )The [Kotlin documentation][moshi_kotlin_docs] explains the required build configuration changes.
-
New: Change how Moshi's generated adapters call constructors. Previous generated code used a combination of the constructor and
copy()method to set properties that have default values. With this update we call the same synthetic constructor that Kotlin uses. This is less surprising though it requires us to generate some tricky code. -
New: Make
Rfc3339DateJsonAdapternull-safe. Previously Moshi would refuse to decode null dates. Restore that behavior by explicitly forbidding nulls withRfc3339DateJsonAdapter().nonNull(). -
New: Require Kotlin 1.3.50 or newer.
-
New:
JsonWriter.valueSink()streams JSON-formatted data inline. Use this to do basic includes of raw JSON within a streamed document. -
New: Support Gradle incremental processing in code gen.
-
New: Improve error messages. This includes better errors when field names and JSON names disagree, and when failing on an unknown field.
-
New: Support default values in
PolymorphicJsonAdapterFactory. -
New: Permit multiple labels for each subtype in
PolymorphicJsonAdapterFactory. The first label is used when writing an object to JSON. -
New: Forbid automatic encoding of platform classes in
kotlinx. As withjava.*,android.*, andkotlin.*Moshi wants you to specify how to encode platform types. -
New:
@JsonClass(generator=...)makes it possible for third-party libraries to provide generated adapters when Moshi's default adapters are insufficient. -
Fix: Simplify wildcard types like
List<? extends Number>to their base typesList<Number>when finding type adapters. This is especially useful with Kotlin where wildcards may be added automatically. -
Fix: Use the correct name when the
@Jsonannotation uses field targeting like@field:Json. -
Fix: Support multiple transient properties in
KotlinJsonAdapter. -
Fix: Don't explode attempting to resolve self-referential type variables like in
Comparable<T extends Comparable<T>>. -
Fix: Don't infinite loop on
skipValue()at the end an object or array. Also disallow callingskipValue()at the end of a document.
-
-
1.8.029 Jul 2019Release notes
Open source →2018-11-09
-
New: Support JSON objects that include type information in the JSON. The new
PolymorphicJsonAdapterFactorywrites a type field when encoding, and reads it when decoding. -
New: Fall back to the reflection-based
KotlinJsonAdapterFactoryif it is enabled and a generated adapter is not found. This makes it possible to use reflection-based JSON adapters in development (so you don't have to wait for code to be regenerated on every build) and generated JSON adapters in production (so you don't need the kotlin-reflect library). -
New: The
peekJson()method onJsonReaderlet you read ahead on a JSON stream without consuming it. This builds on Okio's newBuffer.peek()API. -
New: The
beginFlatten()andendFlatten()methods onJsonWritersuppress unwanted nesting when composing adapters. Previously it was necessary to flatten objects in memory before writing. -
New: Upgrade to Okio 1.16.0. We don't yet require Kotlin-friendly Okio 2.1 but Moshi works fine with that release.
implementation("com.squareup.okio:okio:1.16.0") -
Fix: Don't return partially-constructed adapters when using a Moshi instance concurrently.
-
Fix: Eliminate warnings and errors in generated
.kttriggered by type variance, primitive types, and required values. -
Fix: Improve the supplied rules (
moshi.pro) to better retain symbols used by Moshi. We recommend R8 when shrinking code. -
Fix: Remove code generation companion objects. This API was neither complete nor necessary.
-
-
1.7.029 Jul 2019Release notes
Open source →2018-09-24
-
New:
EnumJsonAdaptermakes it easy to specify a fallback value for unknown enum constants. By default Moshi throws anJsonDataExceptionif it reads an unknown enum constant. With this you can specify a fallback value or null.new Moshi.Builder() .add(EnumJsonAdapter.create(IsoCurrency.class) .withUnknownFallback(IsoCurrency.USD)) .build();Note that this adapter is in the optional
moshi-adaptersmodule.implementation 'com.squareup.moshi:moshi-adapters:1.7.0' -
New: Embed R8/ProGuard rules in the
.jarfile. -
New: Use
@CheckReturnValuein more places. We hope this will encourage you to useskipName()instead ofnextName()for better performance! -
New: Forbid automatic encoding of platform classes in
androidx. As withjava.*,android.*, andkotlin.*Moshi wants you to specify how to encode platform types. -
New: Improve error reporting when creating an adapter fails.
-
New: Upgrade to Okio 1.15.0. We don't yet require Kotlin-friendly Okio 2.x but Moshi works fine with that release.
implementation 'com.squareup.okio:okio:1.15.0' -
Fix: Return false from
JsonReader.hasNext()at document's end. -
Fix: Improve code gen to handle several broken cases. Our generated adapters had problems with nulls, nested parameterized types, private transient properties, generic type aliases, fields with dollar signs in their names, and named companion objects.
-
-
1.6.029 Jul 2019Release notes
Open source →2018-05-14
-
Moshi now supports codegen for Kotlin. We've added a new annotation processor that generates a small and fast JSON adapter for your Kotlin types. It can be used on its own or with the existing
KotlinJsonAdapterFactoryadapter. -
Moshi now resolves all type parameters. Previously Moshi wouldn't resolve type parameters on top-level classes.
-
New: Support up to 255 levels of nesting when reading and writing JSON. Previously Moshi would reject JSON input that contained more than 32 levels of nesting.
-
New: Write encoded JSON to a stream with
JsonWriter.value(BufferedSource). Use this to emit a JSON value without decoding it first. -
New:
JsonAdapter.nonNull()returns a new JSON adapter that forbids explicit nulls in the JSON body. Use this to detect and fail eagerly on unwanted nulls. -
New:
JsonReader.skipName()is likenextName()but it avoids allocating when a name is unknown. Use this whenJsonReader.selectName()returns -1. -
New: Automatic module name of
com.squareup.moshifor use with the Java Platform Module System. This moves moshi-adapters into its own.adapterspackage and forwards the existing adapter. It moves the moshi-kotlin into its own.kotlin.reflectpackage and forwards the existing adapter. -
New: Upgrade to Okio 1.14.0.
<dependency> <groupId>com.squareup.okio</groupId> <artifactId>okio</artifactId> <version>1.14.0</version> </dependency> com.squareup.okio:okio:1.14.0 -
Fix: Fail fast if there are trailing non-whitespace characters in the JSON passed to
JsonAdapter.fromJson(String). Previously such data was ignored! -
Fix: Fail fast when Kotlin types are abstract, inner, or object instances.
-
Fix: Fail fast if
name()is called out of sequence. -
Fix: Handle asymmetric
Type.equals()methods when doing type comparisons. Previously it was possible that a registered type adapter would not be used because itsType.equals()method was not consistent with a user-provided type. -
Fix:
JsonValueReader.selectString()now returns -1 for non-strings instead of throwing. -
Fix: Permit reading numbers as strings when the
JsonReaderwas created from a JSON value. This was always supported when reading from a stream but broken when reading from a decoded value. -
Fix: Delegate to user-adapters in the adapter for Object.class. Previously when Moshi encountered an opaque Object it would only use the built-in adapters. With this change user-installed adapters for types like
Stringwill always be honored.
-