List of usage examples for javax.json JsonValue asJsonArray
default JsonArray asJsonArray()
From source file:org.hyperledger.fabric.sdk.ChaincodeCollectionConfiguration.java
private static JsonArray getJsonArray(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); }//from w w w . j a v a2s.co m if (ret.getValueType() != JsonValue.ValueType.ARRAY) { throw new ChaincodeCollectionConfigurationException( format("property %s wrong type expected array got %s", prop, ret.getValueType().name())); } return ret.asJsonArray(); }
From source file:org.hyperledger.fabric.sdk.NetworkConfig.java
private static JsonArray getJsonValueAsArray(JsonValue value) { return (value != null && value.getValueType() == ValueType.ARRAY) ? value.asJsonArray() : null; }
From source file:org.hyperledger.fabric.sdk.NetworkConfig.java
private static List<JsonObject> getJsonValueAsList(JsonValue value) { if (value != null) { if (value.getValueType() == ValueType.ARRAY) { return value.asJsonArray().getValuesAs(JsonObject.class); } else if (value.getValueType() == ValueType.OBJECT) { List<JsonObject> ret = new ArrayList<>(); ret.add(value.asJsonObject()); return ret; }/* w ww . j av a2 s.c o m*/ } return null; }