Java 如何向json文件添加其他属性

Java 如何向json文件添加其他属性,java,json,attributes,Java,Json,Attributes,我正在使用java中的JSONObject生成一个json文件。 我得到的输出如下: {"entities": [ { "comments": "Yoyo", "contractor": "true", "createdBy": "Moc Naaocb", "dateOfBirth": "191029683619", "department": "qa", "email": "Idpxtt.Qxeisa@hp.com", "employmentDate": "80

我正在使用java中的JSONObject生成一个json文件。 我得到的输出如下:

{"entities": [
  {
  "comments": "Yoyo",
  "contractor": "true",
  "createdBy": "Moc Naaocb",
  "dateOfBirth": "191029683619",
  "department": "qa",
  "email": "Idpxtt.Qxeisa@hp.com",
  "employmentDate": "803891270878",
  "expertise": "javaMaster",
  "firstName": "Idpxtt",
  "gender": "male",
  "imageUrl": "",
  "lastName": "Qxeisa",
  "level": "expert",
  "location": "israel",
  "manager": "Iex",
  "percentageOfTime": "12",
  "periodOfService": "74",
  "role": "ux",
  "team": "platformUI"
 }]}
我实际需要的是在生成的字段之前添加和附加数据(属性),数据是常量。。。它看起来像:

{"entities":[{"entity_type":"employee","lastUpdateTime":0,"properties":{
    "comments": "BlaBlaBla",
    "contractor": "false",
    "createdBy": "Zhsraz Olgaaoqi",
    "dateOfBirth": "101994924814",
    "department": "saas",
    "email": "Ogz.Pqqoaeo@hp.com",
    "employmentDate": "1141914797543",
    "expertise": "javaScriptNinja",
    "firstName": "Ogz",
    "gender": "male",
    "imageUrl": "",
    "lastName": "Pqqoaeo",
    "level": "softwareEngineer",
    "location": "usa",
    "manager": "Jiso",
    "percentageOfTime": "28",
    "periodOfService": "3",
    "role": "systemArchitect",
    "team": "ux"
}]}
任何帮助都将不胜感激。。。 谢谢

json创建代码

JSONObject json = new JSONObject();


        List<Employee> list = new ArrayList<Employee>();
        for(int i=0; i<2; i++) {
            Employee emp = new Employee();
            list.add(emp);
        }

        int print = 1;
        json.accumulate("entities",list);
        System.out.println(json.toString(print));
JSONObject json=new JSONObject();
列表=新的ArrayList();

对于(int i=0;i您如何创建
JSONObject
?请包括代码的相关部分。我正在使用此部分:我预料到了。请包括您编写的使用
JSONObject
的代码。