Fastjson資料綁定
Fastjson DataBind資料庫綁定
Fastjson 完全支援資料庫綁定方法databind, 也非常容易使用.
#Encode
import com.alibaba.fastjson.JSON; Group group = new Group();group.setId(0L);group.setName("admin"); User guestUser = new User(); guestUser.setId(2L); guestUser.setName("guest"); User rootUser = new User(); rootUser.setId(3L); rootUser.setName("root");group.addUser(guestUser);group.addUser(rootUser); String jsonString = JSON.toJSONString(group); System.out.println(jsonString);
#Output
{"id":0,"name":"admin","users":[{"id":2,"name":"guest"},{"id":3,"name":"root"}]}