Example usage for javax.json JsonObject getBoolean

List of usage examples for javax.json JsonObject getBoolean

Introduction

In this page you can find the example usage for javax.json JsonObject getBoolean.

Prototype

boolean getBoolean(String name, boolean defaultValue);

Source Link

Document

Returns the boolean value of the associated mapping for the specified name.

Usage

From source file:org.btc4j.daemon.BtcJsonRpcHttpClient.java

public BtcRawTransaction jsonRawTransaction(JsonValue value) throws BtcException {
    JsonObject object = jsonObject(value);
    if (object == null) {
        return null;
    }// w  w w. j  a  va 2  s . c  o  m
    BtcRawTransaction transaction = new BtcRawTransaction();
    transaction.setHex(object.getString(BTCOBJ_TX_HEX, ""));
    transaction.setTransaction(object.getString(BTCOBJ_TX_TRANSACTION, ""));
    transaction.setVersion(jsonLong(object, BTCOBJ_TX_VERSION));
    transaction.setLockTime(jsonLong(object, BTCOBJ_TX_LOCK_TIME));
    List<BtcInput> inputTransactions = new ArrayList<BtcInput>();
    JsonValue inputs = object.get(BTCOBJ_TX_INPUTS);
    if ((inputs != null) && (inputs.getValueType() == JsonValue.ValueType.ARRAY)
            && (inputs instanceof JsonArray)) {
        JsonArray inputsArray = (JsonArray) inputs;
        for (JsonValue input : inputsArray.getValuesAs(JsonValue.class)) {
            inputTransactions.add(jsonInput(input));
        }
    }
    transaction.setInputs(inputTransactions);
    List<BtcOutput> outputTransactions = new ArrayList<BtcOutput>();
    JsonValue outputs = object.get(BTCOBJ_TX_OUTPUTS);
    if ((outputs != null) && (outputs.getValueType() == JsonValue.ValueType.ARRAY)
            && (outputs instanceof JsonArray)) {
        JsonArray outputsArray = (JsonArray) outputs;
        for (JsonValue output : outputsArray.getValuesAs(JsonValue.class)) {
            outputTransactions.add(jsonOutput(output));
        }
    }
    transaction.setOutputs(outputTransactions);
    transaction.setBlockHash(object.getString(BTCOBJ_TX_BLOCK_HASH, ""));
    transaction.setConfirmations(jsonLong(object, BTCOBJ_TX_CONFIRMATIONS));
    transaction.setTime(jsonLong(object, BTCOBJ_TX_TIME));
    transaction.setBlockTime(jsonLong(object, BTCOBJ_TX_BLOCK_TIME));
    transaction.setComplete(object.getBoolean(BTCOBJ_TX_COMPLETE, true));
    return transaction;
}