Answers for "how to add list of java object into jsonarray"

1

java 8 add whole array to jsonarray

import java.util.ArrayList;
import org.json.JSONArray;
public class ArrayToJson {
   public static void main(String args[]) {
      ArrayList <String> arrayList = new ArrayList<String>();
      arrayList.add("JavaFX");
      arrayList.add("HBase");
      arrayList.add("JOGL");
      arrayList.add("WebGL");
      JSONArray jsArray2 = new JSONArray(arrayList);
      System.out.println(jsArray2);
   }
}
Posted by: Guest on April-03-2020
0

jsonarray to list java

JSONArray data = new JSONArray(); //create data from this -> [{"thumb_url":"tb-1370913834.jpg","event_id":...}]

List<JSONObject> list = data.stream().map(o -> (JSONObject) o).collect(Collectors.toList());
Posted by: Guest on November-19-2020

Code answers related to "how to add list of java object into jsonarray"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language