Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class Main {
    private static Gson sGson = new GsonBuilder().create();

    /**
     * vonvert Object to json string.
     * @param object Object
     * @return json string.
     */
    public static String toJsonString(Object object) {
        try {
            return sGson.toJson(object);
        } catch (Throwable var2) {
            var2.printStackTrace();
            return "";
        }
    }
}