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

com.github.xphsc.json.JSONHelper Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
package com.github.xphsc.json;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ValueFilter;

/**
 * Created by ${huipei.x} on 2017-6-1.
 */
public class JSONHelper extends JSON {

    public static ValueFilter valueFilter=new JSONValueFilter();

    public static final SerializerFeature[] features = {
            SerializerFeature.WriteDateUseDateFormat,
            SerializerFeature.WriteMapNullValue,
            SerializerFeature.WriteNullListAsEmpty,
            SerializerFeature.WriteNullStringAsEmpty,
            SerializerFeature.PrettyFormat,
    };

    public static String toJSON(Object target) {
        return JSONHelper.toJSONString(target, valueFilter, features);
    }

    public static String toJSON(Object target, String dateFormat) {
        JSONHelper.DEFFAULT_DATE_FORMAT = dateFormat;
       return JSONHelper.toJSONString(target, valueFilter, features);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy