List of usage examples for com.google.gson JsonSerializer interface-usage
From source file com.javacreed.examples.gson.part1.LargeDataSerialiser.java
public class LargeDataSerialiser implements JsonSerializer<LargeData> { @Override public JsonElement serialize(final LargeData data, final Type typeOfSrc, final JsonSerializationContext context) { final JsonArray jsonNumbers = new JsonArray();
From source file com.javacreed.examples.gson.part2.AuthorSerialiser.java
public class AuthorSerialiser implements JsonSerializer<Author> { @Override public JsonElement serialize(final Author author, final Type typeOfSrc, final JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject();
From source file com.javacreed.examples.gson.part2.BookSerialiser.java
public class BookSerialiser implements JsonSerializer<Book> { @Override public JsonElement serialize(final Book book, final Type typeOfSrc, final JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("title", book.getTitle());
From source file com.javacreed.examples.gson.part3.AuthorSerialiser.java
public class AuthorSerialiser implements JsonSerializer<Author> { @Override public JsonElement serialize(final Author author, final Type typeOfSrc, final JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject();
From source file com.javacreed.examples.gson.part3.BookSerialiser.java
public class BookSerialiser implements JsonSerializer<Book> { @Override public JsonElement serialize(final Book book, final Type typeOfSrc, final JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("title", book.getTitle());
From source file com.javacreed.examples.gson.part4.LargeDataSerialiser.java
public class LargeDataSerialiser implements JsonSerializer<LargeData> { @Override public JsonElement serialize(final LargeData data, final Type typeOfSrc, final JsonSerializationContext context) { final JsonArray jsonNumbers = new JsonArray();
From source file com.jboss.examples.SQLDateTypeAdapter.java
/**
* A default type adapter for a {@link java.util.Date} object.<br>
* Create a GSON instance that can serialize/deserialize "java.util.Date" objects:
* <pre>
* Gson gson = new GsonBuilder()
* .registerTypeAdapter(new DateTypeAdapter())
From source file com.jd.survey.util.HibernateProxySerializer.java
public class HibernateProxySerializer implements JsonSerializer<HibernateProxy> { @Override public JsonElement serialize(HibernateProxy proxyObj, Type arg1, JsonSerializationContext arg2) { try { GsonBuilder gsonBuilder = new GsonBuilder();
From source file com.jiujie8.choice.core.DateFormatter.java
/** * Formatter for date formats present in the GitHub v2 and v3 API. */ public class DateFormatter implements JsonDeserializer<Date>, JsonSerializer<Date> { private final DateFormat[] formats;
From source file com.julauncher.data.mojang.DateTypeAdapter.java
public class DateTypeAdapter implements JsonDeserializer<Date>, JsonSerializer<Date> { private final DateFormat enUsFormat = DateFormat.getDateTimeInstance(2, 2, Locale.US); private final DateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); @Override public Date deserialize(JsonElement json, Type type, JsonDeserializationContext context)