Java Json listToJsonArray(List list)

Here you can find the source of listToJsonArray(List list)

Description

Method used to build the JSON Array of Strings.

License

Open Source License

Parameter

Parameter Description
list The list of string

Return

A JsonArray object

Declaration

public static JsonArray listToJsonArray(List<String> list) 

Method Source Code

//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();
    }
}

Related

  1. jsonObject(String key, JsonValue val)
  2. jsonObjectToBuilder(JsonObject jo)
  3. jsonPrettyPrinter(Object object)
  4. jsonString(JsonValue value)
  5. jsonValueToJsonString(final JsonValue jsonValue, final String key)
  6. mapToJsonObjectBuilder(Map map)
  7. newObject()
  8. nullable(String value)
  9. objectToJsonDateSerializer(Object ts, final String dateformat)