Example usage for javax.json Json createArrayBuilder

List of usage examples for javax.json Json createArrayBuilder

Introduction

In this page you can find the example usage for javax.json Json createArrayBuilder.

Prototype

public static JsonArrayBuilder createArrayBuilder(Collection<?> collection) 

Source Link

Document

Creates a JSON array builder, initialized with the content of specified collection .

Usage

From source file:org.hyperledger.fabric.sdk.ChaincodeCollectionConfiguration.java

/**
 * Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in YAML format
 *
 * @param configStream A stream opened on a YAML document containing network configuration details
 * @return A new ChaincodeCollectionConfiguration instance
 * @throws InvalidArgumentException/*from   www .jav a 2s . c o m*/
 */
public static ChaincodeCollectionConfiguration fromYamlStream(InputStream configStream)
        throws InvalidArgumentException, ChaincodeCollectionConfigurationException {

    logger.trace("ChaincodeCollectionConfiguration.fromYamlStream...");

    // Sanity check
    if (configStream == null) {
        throw new InvalidArgumentException("ConfigStream must be specified");
    }

    Yaml yaml = new Yaml();

    @SuppressWarnings("unchecked")
    List<Object> map = yaml.load(configStream);

    JsonArrayBuilder builder = Json.createArrayBuilder(map);

    JsonArray jsonConfig = builder.build();
    return fromJsonObject(jsonConfig);
}