Here you can find the source of listToJsonArray(List
Parameter | Description |
---|---|
list | The list of string |
public static JsonArray listToJsonArray(List<String> list)
//package com.java2s; //License from project: Open Source License import java.util.List; import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonArrayBuilder; public class Main { /**//from w w w. j a va 2 s. co m * Method used to build the JSON Array of Strings. * * @param list The list of string * @return A JsonArray object */ public static JsonArray listToJsonArray(List<String> list) { JsonArrayBuilder ab = Json.createArrayBuilder(); for (String element : list) { ab.add(element); } return ab.build(); } }