将JSON对象转换为JSON数组时遇到问题

时间:2020-05-05 12:59:00

标签: java json jersey json-simple

我当前正在使用Json-简单的jar文件,并且需要将json对象转换为json数组,我在很多地方都读到了使用


JSONParser parse = new JSONParser();

JSONObject jobj = (JSONObject) parse.parse(jsonString);


JSONArray arr = jsonObject.getJSONArray("users");

但是无法识别getJSONArray()方法。它说找不到符号。我已经导入了所有的org.json包,但不确定如何运行。

我的JSON来自网址,并且是:

{
  "warnings":[

   ],

  "users":[
      {
         "id":12345678,
         "username":"abc123",
         "firstname":"ABC",
         "lastname":"DEF",
         "fullname":"ABC",
         "email":"abc@gmail.com",
         "department":"Autoz",
         "idnumber":"1234",
         "firstaccess":2552,
         "lastaccess":4242,
         "auth":"ldap",
         "suspended":false,
         "confirmed":true,
         "lang":"en",
         "theme":"",
         "timezone":"99",
         "mailformat":1,
         "description":"Software Engineer",
         "descriptionformat":1,
         "city":"Lahore",
         "profileimageurlsmall":"srwegwegdrz",
         "profileimageurl":"rbdrrebhez"
      }
   ]

}




0 个答案:

没有答案