如何将JSON数组转换为Java ArrayList对象

如何将JSON数组转换为Java ArrayList对象,java,arrays,json,arraylist,Java,Arrays,Json,Arraylist,这是json数组中servlet的结果,该数组使用 /*Converting Json Array to String*/ StringWriter toStringF = new StringWriter(); arrayFood.writeJSONString(toStringF); /*Printing Json Array - String*/ response.getWriter().println(toStri

这是json数组中servlet的结果,该数组使用

 /*Converting Json Array to String*/
         StringWriter toStringF = new StringWriter();
         arrayFood.writeJSONString(toStringF);
         /*Printing Json Array - String*/
         response.getWriter().println(toStringF.toString());
结果表明

[{"Food":{"foodName":"Chicken Tenders","foodDescription":"Deep fried chicken tenders with rice","price":150.0,"foodID":59,"rating":5.0}},{"Food":{"foodName":"Roasted Duck\/Asado Rice","foodDescription":"Roasted duck with asado rice","price":210.0,"foodID":32,"rating":4.0}},{"Food":{"foodName":"Steamed Minced Beef Rice","foodDescription":"Steamed minced beef with rice","price":140.0,"foodID":40,"rating":4.0}},{"Food":{"foodName":"Buffalo Wings","foodDescription":"Deep fried chicken wings coated in hot sauce","price":160.0,"foodID":54,"rating":4.0}},{"Food":{"foodName":"H Burger","foodDescription":"The Hatchery's specialty burger","price":135.0,"foodID":58,"rating":4.0}}] 
我试图在网上搜索如何将JSONArrayString转换为object的arraylist,但是有不同类型的代码和导入,现在我完全不知道该使用哪种。如果有一个更简单的方法来做这件事,它会对我帮助很大

我想将上面的JsonArray字符串转换为一个对象。。类似于FoodName的内容可以设置为它的属性,例如:food.FoodName(jsonObject.getString(“FoodName”)

ArrayList food=new ArrayList();
请参阅此

JSONArray arr=newjsonarray(yourJSONresponse);
列表=新的ArrayList();
对于(int i=0;i
试试Jackson mapper
ArrayList<Food> food = new ArrayList<Food>();
JSONArray arr = new JSONArray(yourJSONresponse);
List<String> list = new ArrayList<String>();
for(int i = 0; i < arr.length(); i++){
    list.add(arr.getJSONObject(i).getString("name"));
}