Java Arraylist Data extraction

前端 未结 3 748
感情败类
感情败类 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:45

    It looks like you want to convert it to Json, using google gson http://code.google.com/p/google-gson/ its very easy

    "Provide simple toJson() and fromJson() methods to convert Java objects to JSON and vice-versa"

    Here is what I mean :

    Gson gson = new Gson();
    gson.toJson(map); //where map is your map object
    

提交回复
热议问题