use of com.alibaba.json.test.entity.Company 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.Company in project fastjson by alibaba.
the class JacksonGroupParser method parseCompany.
private Company parseCompany() throws Exception {
Company company = new Company();
accept(JsonToken.START_OBJECT);
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) {
company.setName(acceptString(tok));
} else if ("description" == name) {
company.setDescription(acceptString(tok));
} else if ("stock" == name) {
company.setStock(acceptString(tok));
} else if ("id" == name) {
company.setId(acceptLong(tok));
} else if ("rootDepartment" == name) {
company.setRootDepartment(parseDepartment());
} else {
throw new RuntimeException("not match property : " + name);
}
}
}
accept(JsonToken.END_OBJECT);
return company;
}
use of com.alibaba.json.test.entity.Company 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