Example usage for com.google.gson JsonArray JsonArray

List of usage examples for com.google.gson JsonArray JsonArray

Introduction

In this page you can find the example usage for com.google.gson JsonArray JsonArray.

Prototype

public JsonArray(int capacity) 

Source Link

Usage

From source file:com.github.ithildir.airbot.util.ApiAiUtil.java

License:Open Source License

public static Fulfillment buildGooglePermissionFulfillment(String key, String permission, Locale locale) {

    Fulfillment fulfillment = new Fulfillment();

    JsonObject dataJsonObject = new JsonObject();

    dataJsonObject.addProperty("@type", "type.googleapis.com/google.actions.v2.PermissionValueSpec");
    dataJsonObject.addProperty("optContext", LanguageUtil.get(locale, key));

    JsonArray permissionsJsonArray = new JsonArray(1);

    permissionsJsonArray.add(permission);

    dataJsonObject.add("permissions", permissionsJsonArray);

    JsonObject systemIntentJsonObject = new JsonObject();

    systemIntentJsonObject.addProperty("intent", "actions.intent.PERMISSION");
    systemIntentJsonObject.add("data", dataJsonObject);

    JsonObject googleJsonObject = new JsonObject();

    googleJsonObject.addProperty("expectUserResponse", true);
    googleJsonObject.add("systemIntent", systemIntentJsonObject);

    fulfillment.setData(Collections.singletonMap("google", googleJsonObject));

    fulfillment.setSpeech("Speechless");

    return fulfillment;
}

From source file:com.github.zhanhb.ishadowsocks.GuiConfigs.java

License:Open Source License

void setConfigs(Collection<JsonObject> configs) {
    JsonArray array = new JsonArray(configs.size());
    for (JsonObject config : configs) {
        array.add(config);/*  w ww . j av  a2 s .  c om*/
    }
    jsonObject.add("configs", array);
}