Java Json Create buildJsonArray(String[][] twoDimensionArray)

Here you can find the source of buildJsonArray(String[][] twoDimensionArray)

Description

Builds two dimensional JsonArray form String[][]

License

Apache License

Declaration

public static JsonArray buildJsonArray(String[][] twoDimensionArray) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;

public class Main {
    /** Builds two dimensional JsonArray form String[][] */
    public static JsonArray buildJsonArray(String[][] twoDimensionArray) {

        JsonArrayBuilder keyboardBuilder = Json.createArrayBuilder();

        for (String[] boardElement : twoDimensionArray) {

            JsonArrayBuilder key = Json.createArrayBuilder();

            for (String keyElement : boardElement) {
                key.add(keyElement);//from ww  w  .j  a v  a 2  s.co m
            }

            keyboardBuilder.add(key.build());
        }

        return keyboardBuilder.build();
    }
}

Related

  1. build(Map map)
  2. buildContentResponse(String userId, String message)
  3. convertToJson(Object myObject)
  4. convertToJson(Object obj)
  5. createArrayBuilder()
  6. createArrayBuilder()