com.squareup.moshi.ToJson Java Examples
The following examples show how to use
com.squareup.moshi.ToJson.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComplexAdapterUnitTest.java From tutorials with MIT License | 5 votes |
@ToJson public JsonDateTime toJson(ZonedDateTime input) { String date = input.toLocalDate().toString(); String time = input.toLocalTime().toString(); String timezone = input.getZone().toString(); return new JsonDateTime(date, time, timezone); }
Example #2
Source File: FromJsonWithoutStrings.java From moshi with Apache License 2.0 | 5 votes |
@ToJson EventJson eventToJson(Event event) { EventJson json = new EventJson(); json.title = event.title; json.begin_date = event.beginDateAndTime.substring(0, 8); json.begin_time = event.beginDateAndTime.substring(9, 14); return json; }
Example #3
Source File: AlternativeAdapterUnitTest.java From tutorials with MIT License | 4 votes |
@ToJson public Long toJson(@EpochMillis Instant input) { return input.toEpochMilli(); }
Example #4
Source File: ColorAdapter.java From NaviBee with GNU General Public License v3.0 | 4 votes |
@ToJson String toJson(@HexColor int value) { return "#" + Integer.toHexString(value); }
Example #5
Source File: SimpleAdapterUnitTest.java From tutorials with MIT License | 4 votes |
@ToJson public String toJson(Author author) { return author.name + " <" + author.email + ">"; }
Example #6
Source File: InstantAdapter.java From u2020 with Apache License 2.0 | 4 votes |
@ToJson public String toJson(Instant instant) { return instant.toString(); }
Example #7
Source File: InstantAdapter.java From u2020-mvp with Apache License 2.0 | 4 votes |
@ToJson public String toJson(Instant instant) { return instant.toString(); }
Example #8
Source File: CardAdapter.java From moshi with Apache License 2.0 | 4 votes |
@ToJson String toJson(Card card) { return card.rank + card.suit.name().substring(0, 1); }
Example #9
Source File: CustomQualifier.java From moshi with Apache License 2.0 | 4 votes |
@ToJson String toJson(@HexColor int rgb) { return String.format("#%06x", rgb); }
Example #10
Source File: MultipleFormats.java From moshi with Apache License 2.0 | 4 votes |
@ToJson String toJson(@CardString Card card) { return card.rank + card.suit.name().substring(0, 1); }
Example #11
Source File: MultipleFormats.java From moshi with Apache License 2.0 | 4 votes |
@ToJson void toJson(JsonWriter writer, Card value, @CardString JsonAdapter<Card> stringAdapter) throws IOException { stringAdapter.toJson(writer, value); }
Example #12
Source File: MoshiConverterFactoryTest.java From jus with Apache License 2.0 | 4 votes |
@ToJson public void write(JsonWriter jsonWriter, AnInterface anInterface) throws IOException { jsonWriter.beginObject(); jsonWriter.name("name").value(anInterface.getName()); jsonWriter.endObject(); }
Example #13
Source File: BigDecimalAdapter.java From rides-java-sdk with MIT License | 4 votes |
@ToJson public float toJson(BigDecimal bigDecimal) { return bigDecimal.floatValue(); }
Example #14
Source File: OAuthScopesAdapter.java From rides-java-sdk with MIT License | 4 votes |
@ToJson String toJson(@OAuthScopes Set<Scope> scopes) { return Scope.toStandardString(scopes); }
Example #15
Source File: AttributeType.java From Hentoid with Apache License 2.0 | 4 votes |
@ToJson String toJson(AttributeType attrType) { return attrType.name(); }
Example #16
Source File: WrappedJsonAdapterTest.java From moshi-lazy-adapters with Apache License 2.0 | 4 votes |
@ToJson String toJson(Throws th) throws IOException { throw new IOException("ThrowingAdapter.toJson"); }
Example #17
Source File: TestUtil.java From moshi-jsonapi with MIT License | 4 votes |
@ToJson String toJson(@Color int rgb) { return String.format("#%06x", rgb); }
Example #18
Source File: LocalDateTimeAdapter.java From droidconat-2016 with Apache License 2.0 | 4 votes |
@ToJson public String toText(LocalDateTime dateTime) { return dateTime.format(formatter); }
Example #19
Source File: DateAdapter.java From secrets-proxy with Apache License 2.0 | 4 votes |
@ToJson String toJson(LocalDateTime date) { return formatter.format(date); }