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

com.github.hdy.common.util.Jsons Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
package com.github.hdy.common.util;

import java.util.List;
import java.util.Map;

public abstract class Jsons {

    public static final String toJSONString(Object o) {
        return ObjectMappers.toJSONString(o);
    }

    public static final String toJSONString(Object o, boolean prettyFormat) {
        return ObjectMappers.toJSONString(o, prettyFormat);
    }

    public static final String toJSONString(Object o, String dateFormat) {
        return ObjectMappers.toJSONString(o, dateFormat);
    }

    public static final String toJSONString(Object o, String dateFormat, boolean prettyFormat) {
        return ObjectMappers.toJSONString(o, dateFormat, prettyFormat);
    }

    public static  T toBean(String jsonString, Class clazz) {
        return ObjectMappers.toBean(jsonString, clazz);
    }

    public static  T toBean(String jsonString, Class clazz, String dateFormat) {
        return ObjectMappers.toBean(jsonString, clazz, ObjectMappers.newMapper(dateFormat));
    }

    public static List toList(String jsonString) {
        return ObjectMappers.toList(jsonString, Object.class);
    }

    public static  List toList(String jsonString, Class clazz) {
        return ObjectMappers.toList(jsonString, clazz);
    }

    public static  List toList(String jsonString, Class clazz, String dateFormat) {
        return ObjectMappers.toList(jsonString, clazz, ObjectMappers.newMapper(dateFormat));
    }

    public static Map toMap(String jsonString) {
        return ObjectMappers.toMap(jsonString);
    }

}