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

ru.greatbit.utils.serialize.Serializer Maven / Gradle / Ivy

package ru.greatbit.utils.serialize;

/**
 * Created by azee on 5/12/14.
 */
public class Serializer {

    /**
     * Unmarshal an oject if we don't now if it is a json or an xml
     * @param data - String with serialised object
     * @param clazz - A class of object to be deserialised
     * @param  - Class of object
     * @return - Unmarshaled object
     * @throws Exception - Serialisation exceptions
     */
    public static T unmarshal(String data, Class clazz) throws Exception {
        try {
            return XmlSerializer.unmarshal(data, clazz);
        }
        catch (javax.xml.bind.UnmarshalException e){
            return JsonSerializer.unmarshal(data, clazz);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy