cc.kave.commons.utils.json.legacy.GsonFileSerializer.java Source code

Java tutorial

Introduction

Here is the source code for cc.kave.commons.utils.json.legacy.GsonFileSerializer.java

Source

/**
 * Copyright (c) 2010, 2011 Darmstadt University of Technology.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 */
package cc.kave.commons.utils.json.legacy;

import java.io.File;
import java.lang.reflect.Type;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

public class GsonFileSerializer implements JsonSerializer<File> {

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

}