编写java后台创建json的时候遇到的问题

private static void createJsonByBean(){
Diaosi wangxiaoer = new Diaosi();
wangxiaoer.setName("王小二");
wangxiaoer.setAge(25.2);
wangxiaoer.setBirthday("1990-01-01");
wangxiaoer.setSchool("蓝翔");
wangxiaoer.setMajor(new String[]{"1","1"});
wangxiaoer.setHas_girlfriend(false);
wangxiaoer.setCar(null);
wangxiaoer.setHouse(null);
wangxiaoer.setComment("这是一个注释");

    System.out.println(new JSONObject(wangxiaoer));
}

控制台输出
{"birthday":"1990-01-01","major":[{"bytes":[{}],"empty":false},{"bytes":[{}],"empty":false}],"school":"蓝翔","car":null,"name":"王小二","has_girlfriend":false,"comment":"这是一个注释","house":null,"age":25.2}

问题是字符串数组major没有输出字符串,输出的bytes类型的字节码,希望知道的回复一下

setMajor
这个major是什么类型的?

你数组先自己转换成JSONArray,然后再合入jsonobject

原因是JSON的JAR包版本太旧了导致的,版本换成20160810刷新即可