Commit Graph

67 Commits

Author SHA1 Message Date
Jesse Wilson
28831b04cf [maven-release-plugin] prepare for next development iteration 2020-08-26 21:38:44 -04:00
Jesse Wilson
cff20193c2 [maven-release-plugin] prepare release moshi-parent-1.10.0 2020-08-26 21:38:36 -04:00
Jesse Wilson
2b5b3b5f8e Simplify the internals of PolymorphicJsonAdapterFactory
We don't need a custom JsonAdapter subclass - we can just call through
unconditionally and fail if the type is unexpected.
2020-07-30 22:34:09 -04:00
Samuele Maci
cd31e5ce52 Extend PolymorphicJsonAdapterFactory to allow custom handling of unknown labels (#1094)
* PolymorphicJsonAdapter uses JsonAdapter as fallback value instead of defaultValue

* PolymorphicJsonAdapterFactory uses fallbackJsonAdapter instead of (defaultValue, defaultValueSet)

* Add testing coverage
2020-07-30 22:01:42 -04:00
sarthak sehgal
976a891568 small correction in given example 2020-05-18 12:11:24 +05:30
Jesse Wilson
b287596c60 [maven-release-plugin] prepare for next development iteration 2019-11-17 09:53:53 -05:00
Jesse Wilson
89a254d644 [maven-release-plugin] prepare release moshi-parent-1.9.2 2019-11-17 09:53:46 -05:00
Jesse Wilson
ca207b2e06 Revert "Don't allow toJson() serialization on polymorphic defau… (#1025)
This reverts commit 6323a0b7c8.

This makes it difficult for a client to take a server-provided value,
modify it, and send it back.
2019-11-16 22:04:57 -05:00
Zac Sweers
6323a0b7c8 Don't allow toJson() serialization on polymorphic default values
This type explicitly indicates an unknown value. This is an explosive case, but an alternative could be to just write null into the writer?
2019-10-31 15:13:22 -04:00
Jesse Wilson
878e9a86d6 [maven-release-plugin] prepare for next development iteration 2019-10-30 23:26:50 -04:00
Jesse Wilson
0af27a39a6 [maven-release-plugin] prepare release moshi-parent-1.9.1 2019-10-30 23:26:43 -04:00
Jesse Wilson
4637950bab [maven-release-plugin] prepare for next development iteration 2019-10-29 07:57:56 -04:00
Jesse Wilson
0c8005bcee [maven-release-plugin] prepare release moshi-parent-1.9.0 2019-10-29 07:57:49 -04:00
Jesse Wilson
02cf66f129 Specify precedence when a subtype has multiple labels 2019-10-26 22:57:00 -04:00
Zac Sweers
1978581b3d Make Rfc3339DateJsonAdapter null-safe (#910)
* Move delegate to private final

* Make Rfc3339DateJsonAdapter null-safe

Resolves #723
2019-09-11 07:22:02 -04:00
Nuno Gomes
687acba760 removed limitation where subtypes should be unique (#856)
* removed limitation where subtypes should be unique

There can be use cases where different type labels should match with the same subtype

* added test for PolymorphicJsonAdapter non unique subtypes
2019-06-20 10:39:19 -05:00
Eric Cochran
be6f3eb2af Unconditionally close the peeked JsonReader. (#810)
It doesn't have an effect now, but this is for the future when closing the peeked source also clears buffers.
2019-02-17 17:00:29 -08:00
Eric Cochran
126c8ea961 Support fail on unknown in PolymorphicJsonAdapterFactory. (#792)
Before, this would fail when skipping to find the index of the label.
Note that this still requires the type to have a label field.
2019-02-15 11:16:12 -08:00
Zac Sweers
fead71bca0 Add support for default values in PolymorphicJsonAdapterFactory
Picking from #741
Resolves #739
2018-12-31 16:21:57 -08:00
Eric Cochran
5f0b2ee8e3 Allow Object base type for PolymorphicJsonAdapterFactory. (#744)
* Allow Object base type for PolymorphicJsonAdapterFactory

This works now.
Using general types like Object, Map, or List for the base type is error-prone, but the checks for these cases are not worth the code cost.

* Delete redundant test.

Let's not encourage users to use Object as a base type by showing it in a test.
2018-11-18 10:15:41 -05:00
Jesse Wilson
6b6c1af907 [maven-release-plugin] prepare for next development iteration 2018-11-09 10:04:52 +11:00
Jesse Wilson
eb7110bf59 [maven-release-plugin] prepare release moshi-parent-1.8.0 2018-11-09 10:04:36 +11:00
Jesse Wilson
89103b6d13 Rename RuntimeJsonAdapterFactory to PolymorphicJsonAdapterFactory
Also expand the documentation.
2018-10-20 00:47:48 -04:00
Jesse Wilson
1896e0f118 Merge pull request #697 from jocmp/master
Make RuntimeJsonAdapterFactory public
2018-10-19 23:33:06 -04:00
Jesse Wilson
6125d8c7b1 Don't decode into memory in RuntimeJsonAdapterFactory
Instead use our new flatten API to decode directly to the stream.
2018-10-19 12:07:58 -04:00
Jesse Wilson
f28bca609a JSON flattening.
This is a new API that makes it possible to do more interesting things
with composition. It's currently write-only; doing composition on reads
is much more difficult.
2018-10-19 10:59:19 -04:00
Jesse Wilson
24ac43a799 Change RuntimeJsonAdapterFactory to peek for type names.
This is a bit awkward because JsonReader.Options doesn't tell you
what its values are.

Also awkward because we don't yet have an equivalent to stream
the encode of the value.
2018-10-09 23:10:31 -04:00
Jesse Wilson
fe22970973 Document how to register JsonAdapters
Closes: https://github.com/square/moshi/issues/698
2018-10-08 11:14:57 -04:00
Josiah Campbell
80f651a3eb Make RuntimeJsonAdapterFactory public 2018-09-27 10:44:55 -05:00
Jesse Wilson
2cb81857ac [maven-release-plugin] prepare for next development iteration 2018-09-24 22:55:49 -04:00
Jesse Wilson
9a652f8788 [maven-release-plugin] prepare release moshi-parent-1.7.0 2018-09-24 22:55:35 -04:00
Jesse Wilson
11241a2b02 Hide RuntimeJsonAdapterFactory for the forthcoming release.
We don't yet have the behavior we want for looking ahead at the type label.
2018-09-24 21:03:20 -04:00
Eric Cochran
810199a442 Disallow Object for RuntimeJsonAdapterFactory's base type. 2018-09-18 17:57:11 -07:00
Eric Cochran
67d07eb450 Add copyright header to EnumJsonAdapterTest. 2018-09-10 15:33:39 -07:00
Jesse Wilson
29bb93bc29 Include labels when encoding with RuntimeJsonAdapterFactory.
Otherwise the adapter is not symmetric.
2018-09-09 17:43:42 -04:00
Eric Cochran
8a8cde0ce3 Allow null fallback enum value in EnumJsonAdapter. 2018-08-31 00:51:34 -07:00
Eric Cochran
29bdc0aa45 Add EnumJsonAdapter to adapters module. (#607) 2018-08-07 15:05:56 -07:00
Eric Cochran
0f1fa3d385 Add RuntimeJsonAdapterFactory to adapters module. (#606)
* Add RuntimeJsonAdapterFactory to adapters module.

* Make RuntimeJsonAdapterFactory create null-safe adapters.

* Add copyright headers.
2018-08-06 04:35:53 -04:00
Eric Cochran
ee873b64f6 Remove unused import. 2018-07-26 17:28:15 -07:00
Jesse Wilson
31ef245eeb [maven-release-plugin] prepare for next development iteration 2018-05-14 23:00:15 -04:00
Jesse Wilson
bf4d1f8693 [maven-release-plugin] prepare release moshi-parent-1.6.0 2018-05-14 23:00:02 -04:00
Jesse Wilson
986cc4c794 [maven-release-plugin] prepare for next development iteration 2018-05-06 21:50:45 -04:00
Jesse Wilson
c2f890879c [maven-release-plugin] prepare release moshi-parent-1.6.0-RC1 2018-05-06 21:50:39 -04:00
Eric Cochran
e5e4fde1dc Use direct link to adapters snapshots. 2018-04-06 16:23:51 -07:00
Szymon Kozak
351bc57554 Change compile to implementation in README (#467) 2018-03-27 17:43:46 -07:00
Jesse Wilson
5ad9d31bd8 Move modules into their own packages.
This sets the Automatic-Module-Name for moshi, moshi-adapters, and moshi-kotlin.
It moves moshi-adapters into its own .adapters package and forwards the existing
adapter. It moves the moshi-kotlin into its own .kotlin package and forwards the
existing adapter.

I'm not certain this is necessary or sufficient, but I think it's the right idea
for JPMS compatibility.
2018-02-07 04:41:06 -05:00
Eric Cochran
9deeb62e77 Add permalink to ISO8601Utils.java. (#425)
This file was removed from master a few months ago.
2018-01-10 21:57:00 -05:00
Benoît Quenaudon
5125fc2f27 Fix builder calls to new API
Update the example with the right API https://github.com/square/moshi/blob/master/moshi/src/main/java/com/squareup/moshi/Moshi.java#L155
2017-08-01 12:58:20 +09:00
John Carlson
76df51bfde Correction to docs of Rfc3339DateJsonAdapter 2017-07-26 14:49:46 -05:00
John Carlson
54c026f5db Document moshi-adapters artifact 2017-07-26 14:35:38 -05:00