mirror of
https://github.com/msfjarvis/msfjarvis.dev.git
synced 2024-06-03 04:18:56 +05:30
Fix typo in moshi post [deploy]
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
03ddfed6b2
commit
87e25ce376
|
@ -189,7 +189,7 @@ And we're set. You'll see the significance of the Options objects now.
|
||||||
beginObject()
|
beginObject()
|
||||||
+ while(hasNext()) {
|
+ while(hasNext()) {
|
||||||
+ when(selectName(topLevelKeys)) {
|
+ when(selectName(topLevelKeys)) {
|
||||||
+ 0 -> heading = readString() ?: throw Util.unexpectedNull(
|
+ 0 -> heading = nextString() ?: throw Util.unexpectedNull(
|
||||||
+ "heading",
|
+ "heading",
|
||||||
+ "text",
|
+ "text",
|
||||||
+ this
|
+ this
|
||||||
|
@ -204,7 +204,7 @@ And we're set. You'll see the significance of the Options objects now.
|
||||||
`reader.hasNext()` is going to continue iterating through the document's tokens until it's completed, which lets us look through the entire document for the parts we need. The `selectName(JsonReader.Options)` method will return the index of a matched key, so `0` there means that the `heading` key was found. In response to that, we want to read it as a string and throw if it is null (since it's non-nullable in `TextParts`). The `Util.unexpectedNull` method is a little nicety that is part of Moshi's internals and is used by its kapt-generated adapters to provide better error messages and we're going to do the same.
|
`reader.hasNext()` is going to continue iterating through the document's tokens until it's completed, which lets us look through the entire document for the parts we need. The `selectName(JsonReader.Options)` method will return the index of a matched key, so `0` there means that the `heading` key was found. In response to that, we want to read it as a string and throw if it is null (since it's non-nullable in `TextParts`). The `Util.unexpectedNull` method is a little nicety that is part of Moshi's internals and is used by its kapt-generated adapters to provide better error messages and we're going to do the same.
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
0 -> heading = readString() ?: throw Util.unexpectedNull(
|
0 -> heading = nextString() ?: throw Util.unexpectedNull(
|
||||||
"heading",
|
"heading",
|
||||||
"text",
|
"text",
|
||||||
this
|
this
|
||||||
|
@ -286,7 +286,7 @@ class TextPartsJsonAdapter {
|
||||||
beginObject()
|
beginObject()
|
||||||
while(hasNext()) {
|
while(hasNext()) {
|
||||||
when(selectName(topLevelKeys)) {
|
when(selectName(topLevelKeys)) {
|
||||||
0 -> heading = readString() ?: throw Util.unexpectedNull(
|
0 -> heading = nextString() ?: throw Util.unexpectedNull(
|
||||||
"heading",
|
"heading",
|
||||||
"text",
|
"text",
|
||||||
this
|
this
|
||||||
|
|
Loading…
Reference in New Issue
Block a user