use of com.alibaba.json.test.entity.Employee in project fastjson by alibaba.
the class GenerateJavaTest method testGenerate.
public void testGenerate() {
Group group = new Group();
group.setName("Alibaba Group");
group.setDescription("Alibaba Group makes it easy for anyone to buy or sell online anywhere in the world. ");
{
Company company = new Company();
company.setId(createId());
company.setName("Alibaba.com");
company.setDescription("Global leader in e-commerce for small businesses");
company.setStock("1688.HK");
group.getCompanies().add(company);
Department root = new Department();
root.setId(createId());
root.setName("B2B");
company.setRootDepartment(root);
{
Department cbu = new Department();
cbu.setId(createId());
cbu.setName("CBU");
root.getChildren().add(cbu);
Employee emp0 = new Employee();
emp0.setName("校长");
emp0.setDescription("神棍敌人姐");
emp0.setAge(3);
emp0.setSalary(new BigDecimal("123456789.0123"));
emp0.setBirthdate(new Date());
emp0.setBadboy(true);
cbu.getMembers().add(emp0);
}
{
Department icbu = new Department();
icbu.setId(createId());
icbu.setName("ICBU");
root.getChildren().add(icbu);
}
}
{
Company company = new Company();
company.setId(createId());
company.setName("Taobao");
company.setDescription("China's largest online retail website and one-stop platform for shopping, socializing and information sharing");
group.getCompanies().add(company);
}
{
Company company = new Company();
company.setId(createId());
company.setName("Alipay");
company.setDescription("China's leading third-party online payment platform");
group.getCompanies().add(company);
}
{
Company company = new Company();
company.setId(createId());
company.setName("Alibaba Cloud Computing");
company.setDescription("Developer of advanced data-centric cloud computing services");
group.getCompanies().add(company);
}
{
Company company = new Company();
company.setId(createId());
company.setName("China Yahoo");
company.setDescription("One of China's leading Internet portals");
group.getCompanies().add(company);
}
String jsonString = JSON.toJSONString(group, true);
System.out.println(jsonString);
}
use of com.alibaba.json.test.entity.Employee in project fastjson by alibaba.
the class JacksonGroupParser method parseEmployee.
private Employee parseEmployee() throws Exception {
accept(JsonToken.START_OBJECT);
Employee emp = new Employee();
for (; ; ) {
JsonToken tok = parser.getCurrentToken();
if (tok == JsonToken.END_OBJECT) {
break;
}
if (tok == JsonToken.FIELD_NAME) {
String name = parser.getCurrentName();
tok = parser.nextToken();
if ("name" == name) {
emp.setName(acceptString(tok));
} else if ("description" == name) {
emp.setDescription(acceptString(tok));
} else if ("number" == name) {
emp.setNumber(acceptString(tok));
} else if ("id" == name) {
emp.setId(acceptLong(tok));
} else if ("age" == name) {
emp.setAge(acceptInteger(tok));
} else if ("salary" == name) {
emp.setSalary(acceptBigDecimal(tok));
} else if ("birthdate" == name) {
emp.setBirthdate(new Date(acceptLong(tok)));
} else if ("badboy" == name) {
emp.setBadboy(acceptBoolean(tok));
} else {
throw new RuntimeException("not match property : " + name);
}
}
}
accept(JsonToken.END_OBJECT);
return emp;
}
use of com.alibaba.json.test.entity.Employee in project fastjson by alibaba.
the class ObjectEncodePerformanceTest method createObject.
private Object createObject() {
Group group = new Group();
group.setName("Alibaba Group");
group.setDescription("Alibaba Group makes it easy for anyone to buy or sell online anywhere in the world. ");
{
Company company = new Company();
company.setId(createId());
company.setName("Alibaba.com");
company.setDescription("Global leader in e-commerce for small businesses");
company.setStock("1688.HK");
group.getCompanies().add(company);
Department root = new Department();
root.setId(createId());
root.setName("B2B");
company.setRootDepartment(root);
{
Department cbu = new Department();
cbu.setId(createId());
cbu.setName("CBU");
root.getChildren().add(cbu);
Employee emp0 = new Employee();
emp0.setName("校长");
emp0.setDescription("神棍敌人姐");
emp0.setAge(3);
emp0.setSalary(new BigDecimal("123456789.0123"));
emp0.setBirthdate(new Date());
emp0.setBadboy(true);
cbu.getMembers().add(emp0);
}
{
Department icbu = new Department();
icbu.setId(createId());
icbu.setName("ICBU");
root.getChildren().add(icbu);
}
}
{
Company company = new Company();
company.setId(createId());
company.setName("Taobao");
company.setDescription("China's largest online retail website and one-stop platform for shopping, socializing and information sharing");
group.getCompanies().add(company);
}
{
Company company = new Company();
company.setId(createId());
company.setName("Alipay");
company.setDescription("China's leading third-party online payment platform");
group.getCompanies().add(company);
}
{
Company company = new Company();
company.setId(createId());
company.setName("Alibaba Cloud Computing");
company.setDescription("Developer of advanced data-centric cloud computing services");
group.getCompanies().add(company);
}
{
Company company = new Company();
company.setId(createId());
company.setName("China Yahoo");
company.setDescription("One of China's leading Internet portals");
group.getCompanies().add(company);
}
return group;
}
Aggregations