How to convert ArrayList of custom class to JsonArray in Java?

前端 未结 7 2187
一个人的身影
一个人的身影 2021-02-03 22:18

I am trying to convert ArrayList of custom class to JsonArray. Below is my code. It executes fine but some JsonArray elements come as zeros even though they are numbers in the A

7条回答
  •  甜味超标
    2021-02-03 22:47

    List<> is a normal java object, and can be successfully transformed using standard gson object api. List in gson looks like this:

    "libraries": [
        {
          //Containing object 
        },
        {
          //Containing object 
        }
       ],
    ...
    

提交回复
热议问题