开源项目主页:https://github.com/dongfangshangren/Zson
import java.util.List;
import java.util.ArrayList;
import java.lang.reflect.Type;
import org.zson.JsonSerializer;
import org.zson.TypeReference;
import org.zson.JsonDeserializer;
import test.bean.SomeBean;
public class TestZson{
public static void main(){
//Serialize
List<SomeBean> list=new ArrayList<SomeBean>();
String json=new JsonSerializer().prettyFormat(2).ignoreNull(false)
.dateFormat("yyyy-MM-dd").serialize(list);
//Deserilize
Type type=new TypeReference<List<SomeBean>>(){}.getType();
List<SomeBean> result=(List<SomeBean>)new JsonDeserializer().deserialize(json,type);
}
}