All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kfuntak.gwt.json.serialization.client.SerializerHelper Maven / Gradle / Ivy

Go to download

GWT Professional JSON Serializer allows you to serialize any JSON text into a java object (and reverse). It is crucial functionality when there is no GWT-RPC on server side. This JSON serializer allows easy connecting GWT client side to any standard server side technology.

The newest version!
package com.kfuntak.gwt.json.serialization.client;

import java.util.Date;

import com.google.gwt.json.client.JSONNull;
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.json.client.JSONBoolean;

;

public class SerializerHelper {

    public static JSONValue getString(String string) {
        if (string == null) {
            return JSONNull.getInstance();
        }
        return new JSONString(string);
    }

    public static JSONValue getBoolean(Boolean boolValue) {
        if (boolValue == null) {
            return JSONNull.getInstance();
        }
        return JSONBoolean.getInstance(boolValue);
    }

    public static JSONValue getNumber(Number number) {
        if (number == null) {
            return JSONNull.getInstance();
        }
        return new JSONNumber(number.doubleValue());
    }

    public static JSONValue getChar(Character character) {
        if (character == null) {
            return JSONNull.getInstance();
        }
        return new JSONString(new String(new char[]{character}));
    }

    public static JSONValue getDate(Date date) {
        if (date == null) {
            return JSONNull.getInstance();
        }
        return new JSONNumber(date.getTime());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy