Example usage for javax.json JsonValue toString

List of usage examples for javax.json JsonValue toString

Introduction

In this page you can find the example usage for javax.json JsonValue toString.

Prototype

@Override
String toString();

Source Link

Document

Returns JSON text for this JSON value.

Usage

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

private static int getJsonInt(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException {
    JsonValue ret = obj.get(prop);
    if (ret == null) {
        throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop));
    }/*from  w  ww .  j  a v  a 2 s.  c o m*/
    if (ret.getValueType() != JsonValue.ValueType.NUMBER) {
        throw new ChaincodeCollectionConfigurationException(
                format("property %s wrong type expected number got %s", prop, ret.getValueType().name()));
    }

    return Integer.parseInt(ret.toString());

}

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

private static void setPeerRole(String channelName, PeerOptions peerOptions, JsonObject jsonPeer, PeerRole role)
        throws NetworkConfigurationException {
    String propName = roleNameRemap(role);
    JsonValue val = jsonPeer.get(propName);
    if (val != null) {
        Boolean isSet = getJsonValueAsBoolean(val);
        if (isSet == null) {
            // This is an invalid boolean value
            throw new NetworkConfigurationException(
                    format("Error constructing channel %s. Role %s has invalid boolean value: %s", channelName,
                            propName, val.toString()));
        }/*from w  ww  .j  av  a 2  s  .co  m*/
        if (isSet) {
            peerOptions.addPeerRole(role);
        }
    }
}

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

private static String getJsonValueAsNumberString(JsonValue value) {
    return (value != null && value.getValueType() == ValueType.NUMBER) ? value.toString() : null;
}

From source file:org.optaplanner.examples.conferencescheduling.persistence.ConferenceSchedulingCfpDevoxxImporter.java

private List<Speaker> extractSpeakerList(String confType, JsonObject talkObject, String code, String title) {
    List<Speaker> speakerList = new ArrayList<>();

    String mainSpeakerName = talkObject.getString("mainSpeaker");
    if (Arrays.asList(IGNORED_SPEAKER_NAMES).contains(mainSpeakerName)) {
        return speakerList;
    }/*  ww  w .  j a v  a 2 s  .com*/

    speakerList.add(getSpeakerOrCreateOneIfNull(confType, code, title, mainSpeakerName));
    if (talkObject.containsKey("secondarySpeaker")) {
        String secondarySpeakerName = talkObject.getString("secondarySpeaker");
        speakerList.add(getSpeakerOrCreateOneIfNull(confType, code, title, secondarySpeakerName));
    }

    if (talkObject.containsKey("otherSpeakers")) {
        JsonArray otherSpeakersArray = talkObject.getJsonArray("otherSpeakers");
        for (JsonValue otherSpeakerName : otherSpeakersArray) {
            speakerList.add(getSpeakerOrCreateOneIfNull(confType, code, title,
                    otherSpeakerName.toString().replaceAll("\"", "")));
        }
    }

    return speakerList;
}