Commit graph

264 commits

Author SHA1 Message Date
Thomas Vos
f68035859e Fix typo in documentation for JsonReader.peekJson() (#797) 2019-02-15 11:15:38 -08:00
Eric Cochran
737f58cecb
Unignore ObjectAdapterTest's toJsonCoercesRuntimeTypeForMaps 2018-11-26 17:04:40 -08:00
Zac Sweers
dbe7bfa15f Use faster isAnnotationPresent check
Followup from https://github.com/square/moshi/pull/749#discussion_r235224202
2018-11-20 17:20:09 -08:00
Jesse Wilson
afb82cb3e8
Merge pull request #751 from square/eric.platform-type
Improve error message for platform types.
2018-11-20 20:05:13 -05:00
Zac Sweers
c64138bf0a
Refuse kotlin classes in ClassJsonAdapter (#749)
* Refuse kotlin classes in ClassJsonAdapter

* Fail()

* Tweak message
2018-11-19 23:36:52 -08:00
Eric Cochran
7d1657d76c
Fix peekJson Javadoc paragraph formatting. 2018-11-19 10:42:41 -08:00
Eric Cochran
a920b9be3a Improve error message for platform types.
The error message about platform types will never contain qualifiers.
Also, simplify platform type check.
2018-11-19 02:31:07 -08:00
Eric Cochran
5bf14098d1 Fix infinite loop when calling skipValue at the end an object or array.
Fail with a clear message. This is useful when iteratoring through an array, making assumptions about the size without using hasNext.

Also, disallow calling skipValue at the end of a document. This is a behavior change.
2018-11-16 10:20:38 -08: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
Eric Cochran
878b3ff93b Add CheckReturnValue annotation to peekJson. (#736)
* Add CheckReturnValue annotation to peekJson.

* Suppress test warning.
2018-11-09 07:41:45 +11:00
Eric Cochran
81db25825d
Add CheckReturnValue annotation to beginFlatten. 2018-11-06 10:15:01 -08:00
Eric Cochran
5c41565f39 Fall back to reflection when generated adapter is not found. (#728)
* Fall back to reflection when generated adapter is not found.

This is handy for development builds where kapt is disabled and models still have @JsonClass(generatedAdapter = true).

* Add test for Kotlin reflection fallback behavior.
2018-11-06 18:28:36 +11:00
Jesse Wilson
1acc70dd70
Merge pull request #710 from technoir42/keep-nested-class-adapters
Retain generated JsonAdapters for nested classes
2018-11-04 08:23:23 +10:00
technoir
9e3d2345f9 Retain generated JsonAdapters for nested classes 2018-11-04 00:52:05 +03:00
Jesse Wilson
978d4dddd5 Fix prose in deferred adapters 2018-11-03 22:36:17 +11:00
Eric Cochran
fe7ba863b4
Use BufferedSource.getBuffer(). 2018-11-02 17:03:45 -07:00
Jesse Wilson
ce65ff5527 Fix a race condition on deferred adapters
This changes how we lookup and cache adapters. Previously we were pretty
optimistic about putting adapters in the cache; these adapters could have
depended upon stubs that were incomplete.

Now we're a lot more careful: we only put adapters in the cache if the
root object that triggered a set of recursive calls was constructed
successfully.

Closes: https://github.com/square/moshi/issues/679
2018-10-22 21:06:31 -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
Eric Cochran
931673c264
Fix Javadoc code formatting for JsonReader.peek(). 2018-10-08 12:48:44 -07:00
Jesse Wilson
7055391230 Implement peekJson() for JsonUtf8Reader
This required an upgrade to Okio 1.16.0.
2018-10-08 11:44:03 -04:00
Jesse Wilson
eb64d186a6
Merge pull request #680 from square/jwilson.0923.peekvalue
Implement peekJson() for JsonValueReader
2018-10-07 16:59:20 -04:00
sergey
b5db9fa7f1 Always keep fields of annotated enums 2018-09-27 00:54:39 +03:00
Gabriel Ittner
b7055944a9 Proguard config: keep field names of annotated enums (#691)
closes #689
2018-09-25 11:52:05 -07:00
Jesse Wilson
00dcac60d4 Implement peekJson() for JsonValueReader
The JsonUtf8Reader variant relies on an update to Okio that we're
not quite ready for.

This one became straightforward after I changed out the iterators
to be cloneable. That's necessary to split one iterator into two.
It's too bad the platform's built-in iterators are not cloneable;
that would have been convenient and potentially more efficient.

Related to https://github.com/square/moshi/issues/672
2018-09-24 23:21:07 -04: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
026d16ba68 Don't include the 'internal' package in Javadocs 2018-09-24 22:35:29 -04:00
Jesse Wilson
735f0c39f7 Upgrade Kotlin, AssertJ, compile-testing, and kotlin-metadata dependencies 2018-09-24 21:48:25 -04:00
Eric Cochran
5a46cd6bd5
Use BufferedSource.indexOf instead of loops. (#677)
Cleanup of a rare code path for block comments in lenient readers.
2018-09-20 21:20:11 -07:00
Benoit Quenaudon
df730cafb9
Fix JsonQualifiers test 2018-09-13 15:02:06 -04:00
Eric Cochran
895c3ddb49 Track field names in the adapter lookup stack. (#616)
* Track field names in the adapter lookup stack.

This allows for an error message that includes field names to track down the cause of adapter creation failure for deeply nested structures.

* Use a single stack in Moshi client.

* Make optional fieldName parameter public API.

* Simplify error message.
2018-09-12 22:27:58 -04:00
Jesse Wilson
83b6b26e63
Merge pull request #659 from square/eric.exception-cause
Add exception cause for method adapter creation.
2018-09-12 22:24:22 -04:00
Benoit Quenaudon
c606f43a3d
Don't reflect on androidX 2018-09-12 15:11:42 -04:00
Eric Cochran
46a42bc7ed Add exception cause for method adapter creation. 2018-09-11 22:25:09 -07:00
Jesse Wilson
76cd590ca3 Generate nicer stacktraces when creating a generated adapter fails.
Otherwise we end up with many InvocationTargetExceptions layered in, which makes
it difficult to identify what actually failed.
2018-09-11 22:02:54 -04:00
Eric Cochran
e7c745aac8 Make generated adapters null-safe.
This is in alignment with the lookup for Java and Kotlin reflective adapters.
2018-09-10 16:31:24 -07:00
Jesse Wilson
2a593da06c
Merge pull request #628 from gabrielittner/master
Embed ProGuard rules in the jar
2018-09-08 14:58:44 -04:00
Gabriel Ittner
24e0777ebd
add period to comments 2018-09-07 08:04:56 +02:00
Jorge Antonio Díaz-Benito Soriano
56e67088a9
Remove unnecessary isAccessible check
https://github.com/square/moshi/issues/624
2018-08-19 20:46:43 +02:00
Gabriel Ittner
4bbc5b2ff8
Embed ProGuard rules in the jar 2018-08-19 11:14:47 +02:00
Eric Cochran
137ffc992f
Fix incorrect path in enum adapter error message. (#613) 2018-08-06 22:46:41 -07:00
Eric Cochran
627e62f507 Fix hasNext to return false at document end. 2018-06-22 15:18:22 -07:00
Eric Cochran
df3a6ce2ae
Remove redundant "to" in doc. 2018-05-23 12:28:07 -07:00
Eric Cochran
d31f3c2482 Add more CheckReturnValues for JsonReader.
This encourages skipName over nextName.
2018-05-15 18:37:29 -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
Jesse Wilson
7b1177adbc
Merge pull request #503 from square/eric.write-from-source
Allow writing out raw JSON.
2018-05-06 21:11:34 -04:00