Example usage for com.google.gson JsonSerializer interface-usage

List of usage examples for com.google.gson JsonSerializer interface-usage

Introduction

In this page you can find the example usage for com.google.gson JsonSerializer interface-usage.

Usage

From source file cc.kave.commons.utils.json.legacy.ISO8601DateParser.java

public class ISO8601DateParser implements JsonDeserializer<Date>, JsonSerializer<Date> {

    @Override
    public Date deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context)
            throws JsonParseException {

From source file cc.kave.commons.utils.json.legacy.MultimapTypeAdapter.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public class MultimapTypeAdapter implements JsonSerializer<Multimap>, JsonDeserializer<Multimap> {

    @Override
    public JsonElement serialize(final Multimap src, final Type typeOfSrc, final JsonSerializationContext context) {
        return context.serialize(src.asMap(), createMapType(typeOfSrc));

From source file cc.kave.commons.utils.json.legacy.ObjectUsageFeatureRedirector.java

public class ObjectUsageFeatureRedirector<T> implements JsonSerializer<T> {
    @Override
    public JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context) {
        return context.serialize(src, UsageFeature.class);
    }
}

From source file cc.kave.commons.utils.json.LocalDateTimeConverter.java

public class LocalDateTimeConverter implements JsonSerializer<LocalDateTime>, JsonDeserializer<LocalDateTime> {

    @Override
    public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(src));
    }

From source file cc.recommenders.utils.gson.GsonFileSerializer.java

public class GsonFileSerializer implements JsonSerializer<File> {

    @Override
    public JsonElement serialize(final File src, final Type typeOfSrc, final JsonSerializationContext context) {
        return new JsonPrimitive(src.toString());
    }

From source file cc.recommenders.utils.gson.GsonNameSerializer.java

public class GsonNameSerializer implements JsonSerializer<IName> {
    @Override
    public JsonElement serialize(final IName src, final Type typeOfSrc, final JsonSerializationContext context) {
        return new JsonPrimitive(src.getIdentifier());
    }
}

From source file cc.recommenders.utils.gson.ISO8601DateParser.java

public class ISO8601DateParser implements JsonDeserializer<Date>, JsonSerializer<Date> {

    @Override
    public Date deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context)
            throws JsonParseException {

From source file cc.recommenders.utils.gson.MultimapTypeAdapter.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public class MultimapTypeAdapter implements JsonSerializer<Multimap>, JsonDeserializer<Multimap> {

    @Override
    public JsonElement serialize(final Multimap src, final Type typeOfSrc, final JsonSerializationContext context) {
        return context.serialize(src.asMap(), createMapType(typeOfSrc));

From source file cc.recommenders.utils.gson.ObjectUsageFeatureRedirector.java

public class ObjectUsageFeatureRedirector<T> implements JsonSerializer<T> {
    @Override
    public JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context) {
        return context.serialize(src, UsageFeature.class);
    }
}

From source file ch.epfl.leb.sass.models.fluorophores.internal.DefaultFluorophore.java

class DefaultFluorophoreSerializer implements JsonSerializer<DefaultFluorophore> {
    @Override
    public JsonElement serialize(DefaultFluorophore src, Type typeOfSrc, JsonSerializationContext context) {
        JsonObject result = new JsonObject();
        result.add("id", new JsonPrimitive(src.getId()));
        result.add("x", new JsonPrimitive(src.x));