mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
3.1 KiB
3.1 KiB
Change Log
Version 1.1.0
2016-01-19
- New: Support RFC 7159, the latest JSON specification. This removes the constraint that the root value must be an array or an object. It may now take any value: array, object, string, number, boolean, or null. Previously this was only permitted if the adapter was configured to be lenient.
- New: Enum constants may be annotated with
@Jsonto customize their encoded value. - New: Create new builder from Moshi instance with
Moshi.newBuilder(). - New:
Types.getRawType()andTypes.collectionElementType()APIs to assist in defining generic type adapter factories.
Version 1.0.0
2015-09-27
- API Change: Replaced
new JsonReader()withJsonReader.of()andnew JsonWriter()withJsonWriter.of(). If your code calls either of these constructors it will need to be updated to call the static factory method instead. - API Change: Don’t throw
IOExceptiononJsonAdapter.toJson(T). Code that calls this method may need to be fixed to no longer catch an impossibleIOException. - Fix: the JSON adapter for
Objectno longer fails when encounteringnullin the stream. - New:
@Jsonannotation can customize a field's name. This is particularly handy for fields whose names are Java keywords, likedefaultorpublic. - New:
Rfc3339DateJsonAdapterconverts between ajava.util.Dateand a string formatted with RFC 3339 (like2015-09-26T18:23:50.250Z). This class is in the newmoshi-adapterssubproject. You will need to register this adapter if you want this date formatting behavior. See it in action in the dates example. - New:
Moshi.adapter()keeps a cache of all created adapters. For best efficiency, application code should keep a reference to required adapters in a field. - New: The
Typesfactory class makes it possible to compose types likeList<Card>orMap<String, Integer>. This is useful to look up JSON adapters for parameterized types. - New:
JsonAdapter.failOnUnknown()returns a new JSON adapter that throws if an unknonw value is encountered on the stream. Use this in development and debug builds to detect typos in field names. This feature shouldn’t be used in production because it makes migrations very difficult.
Version 0.9.0
2015-06-16
- Databinding for primitive types, strings, enums, arrays, collections, and maps.
- Databinding for plain old Java objects.
- JSONPath support for both
JsonReaderandJsonWriter. - Throw
JsonDataExceptionwhen there’s a data binding problem. - Adapter methods:
@ToJsonand@FromJson. - Qualifier annotations:
@JsonQualifierto permit different type adapters for the same Java type. - Imported code from Gson:
JsonReader,JsonWriter. Also some internal classes:LinkedHashTreeMapfor hash-collision avoidance andTypesfor typesafe databinding.