Java Arraylist Data extraction

前端 未结 3 753
感情败类
感情败类 2021-01-25 06:47

How would you extract the data as follows:

I want to extract from this arraylist:

[{itemname=Original, number=12}, {itemname=BBQ, number=23}, {itemname=C         


        
3条回答
  •  感动是毒
    2021-01-25 07:30

    Thanks for the tip - I have changed to the following code:

      ArrayList> list = new ArrayList>();
      Gson gson = new Gson();
      for (int i = 0; i<7;i++) {
         HashMap map = new HashMap();
         map.put("itemname",chips[i]);
         map.put("number",chipentry[i]);
         list.add(map);
         System.out.println(gson.toJson(map));
      }
    

    And the result is http://imgur.com/E7uds.png

    I imported com.google.gson.Gson, is there something else I'm missing? Please excuse my newbness and thanks for the help!

提交回复
热议问题