com.eclipsesource.json.JsonObject.getString()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中com.eclipsesource.json.JsonObject.getString()方法的一些代码示例,展示了JsonObject.getString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonObject.getString()方法的具体详情如下:
包路径:com.eclipsesource.json.JsonObject
类名称:JsonObject
方法名:getString

JsonObject.getString介绍

[英]Returns the String value of the member with the specified name in this object. If this object does not contain a member with this name, the given default value is returned. If this object contains multiple members with the given name, the last one is picked. If this member's value does not represent a JSON string, an exception is thrown.
[中]返回此对象中具有指定名称的成员的String值。如果此对象不包含具有此名称的成员,则返回给定的默认值。如果此对象包含多个具有给定名称的成员,将拾取最后一个成员。如果此成员的值不表示JSON字符串,则会引发异常。

代码示例

代码示例来源:origin: io.thorntail/config-api-generator

public String getModuleName() {
  return this.json.getString( "module", "unkonwn" );
}

代码示例来源:origin: org.wildfly.swarm/config-api-generator

public String getModuleName() {
  return this.json.getString( "module", "unkonwn" );
}

代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet

public synchronized WalletBalance getWalletInfo()
    throws WalletCallException, IOException, InterruptedException {
  WalletBalance balance = new WalletBalance();
  JsonObject objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", null);
  balance.transparentBalance = Double.valueOf(objResponse.getString("transparent", "-1"));
  balance.privateBalance = Double.valueOf(objResponse.getString("private", "-1"));
  balance.totalBalance = Double.valueOf(objResponse.getString("total", "-1"));
  objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", "0");
  balance.transparentUnconfirmedBalance = Double.valueOf(objResponse.getString("transparent", "-1"));
  balance.privateUnconfirmedBalance = Double.valueOf(objResponse.getString("private", "-1"));
  balance.totalUnconfirmedBalance = Double.valueOf(objResponse.getString("total", "-1"));
  return balance;
}

代码示例来源:origin: ZencashOfficial/zencash-swing-wallet-ui

public synchronized WalletBalance getWalletInfo()
  throws WalletCallException, IOException, InterruptedException
{
  WalletBalance balance = new WalletBalance();
  JsonObject objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", null);
  balance.transparentBalance = Double.valueOf(objResponse.getString("transparent", "-1"));
  balance.privateBalance     = Double.valueOf(objResponse.getString("private", "-1"));
  balance.totalBalance       = Double.valueOf(objResponse.getString("total", "-1"));
  objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", "0");
  balance.transparentUnconfirmedBalance = Double.valueOf(objResponse.getString("transparent", "-1"));
  balance.privateUnconfirmedBalance     = Double.valueOf(objResponse.getString("private", "-1"));
  balance.totalUnconfirmedBalance       = Double.valueOf(objResponse.getString("total", "-1"));
  return balance;
}

代码示例来源:origin: org.activecomponents.jadex/jadex-json

/**
 *  Find the class of an object.
 *  @param object The object.
 *  @return The objects class.
 */
public static Class<?> findClazzOfJsonObject(JsonObject object, ClassLoader targetcl)
{
  Class<?> ret = null;
  String clname = object.getString(CLASSNAME_MARKER, null);
  if(clname!=null)
    ret = SReflect.classForName0(clname, targetcl);
  return ret;
}

代码示例来源:origin: de.ruedigermoeller/kontraktor-http

public static String getVersion(String nodeModulePath) throws IOException {
  File pack = new File(nodeModulePath,"package.json");
  if ( pack.exists() ) {
    String version = null;
    JsonObject pjson = Json.parse(new FileReader(pack)).asObject();
    return pjson.getString("version", null);
  }
  return null;
}

代码示例来源:origin: com.lordofthejars.diferencia/diferencia-java-core

private static List<ErrorDetail> parseErrorDetails(JsonObject stat) {
  final List<ErrorDetail> errorDetailsList = new ArrayList<>();
  final JsonValue errorDetails = stat.get("errorDetails");
  if (errorDetails != null && !errorDetails.isNull()) {
    for (JsonValue errorInfo : errorDetails.asArray()) {
      final JsonObject errorInfoObject = errorInfo.asObject();
      final String fullUri = errorInfoObject.getString("fullURI", "");
      final String originalBody = errorInfoObject.getString("originalBody", "");
      final String headerDiff = errorInfoObject.getString("headerDiff", "");
      final String bodyDiff = errorInfoObject.getString("bodyDiff", "");
      final String statusDiff = errorInfoObject.getString("statusDiff", "");
      final Map<String, String> headers = parseHeaders(errorInfoObject);
      errorDetailsList.add(new ErrorDetail(fullUri, headers, originalBody, bodyDiff, headerDiff, statusDiff));
    }
  }
  return errorDetailsList;
}

代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet

public synchronized String[] getWalletPublicAddressesWithUnspentOutputs()
    throws WalletCallException, IOException, InterruptedException {
  JsonArray jsonUnspentOutputs = executeCommandAndGetJsonArray("listunspent", "0");
  Set<String> addresses = new HashSet<>();
  for (int i = 0; i < jsonUnspentOutputs.size(); i++) {
    JsonObject outp = jsonUnspentOutputs.get(i).asObject();
    addresses.add(outp.getString("address", "ERROR!"));
  }
  return addresses.toArray(new String[0]);
}

代码示例来源:origin: ZencashOfficial/zencash-swing-wallet-ui

public synchronized String[] getWalletPublicAddressesWithUnspentOutputs()
  throws WalletCallException, IOException, InterruptedException
{
  JsonArray jsonUnspentOutputs = executeCommandAndGetJsonArray("listunspent", "0");
  Set<String> addresses = new HashSet<>();
  for (int i = 0; i < jsonUnspentOutputs.size(); i++)
  {
    JsonObject outp = jsonUnspentOutputs.get(i).asObject();
    addresses.add(outp.getString("address", "ERROR!"));
  }
  return addresses.toArray(new String[0]);
 }

代码示例来源:origin: ZencashOfficial/zencash-swing-wallet-ui

public synchronized String[] getWalletAllPublicAddresses()
  throws WalletCallException, IOException, InterruptedException
{
  JsonArray jsonReceivedOutputs = executeCommandAndGetJsonArray("listreceivedbyaddress", "0", "true");
  Set<String> addresses = new HashSet<>();
  for (int i = 0; i < jsonReceivedOutputs.size(); i++)
  {
      JsonObject outp = jsonReceivedOutputs.get(i).asObject();
      addresses.add(outp.getString("address", "ERROR!"));
  }
  return addresses.toArray(new String[0]);
}

代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet

public synchronized String[] getWalletAllPublicAddresses()
    throws WalletCallException, IOException, InterruptedException {
  JsonArray jsonReceivedOutputs = executeCommandAndGetJsonArray("listreceivedbyaddress", "0", "true");
  Set<String> addresses = new HashSet<>();
  for (int i = 0; i < jsonReceivedOutputs.size(); i++) {
    JsonObject outp = jsonReceivedOutputs.get(i).asObject();
    addresses.add(outp.getString("address", "ERROR!"));
  }
  return addresses.toArray(new String[0]);
}

代码示例来源:origin: dernasherbrezon/r2cloud

@Override
public ModelAndView doPost(IHTTPSession session) {
  JsonValue request = Json.parse(WebServer.getRequestBody(session));
  if (!request.isObject()) {
    return new BadRequest("expected object");
  }
  String username = ((JsonObject) request).getString("username", null);
  String password = ((JsonObject) request).getString("password", null);
  return doLogin(auth, username, password);
}

代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet

public synchronized boolean isCompletedOperationSuccessful(String opID)
    throws WalletCallException, IOException, InterruptedException {
  JsonArray response = this.executeCommandAndGetJsonArray(
      "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
  JsonObject jsonStatus = response.get(0).asObject();
  String status = jsonStatus.getString("status", "ERROR");
  Log.info("Operation " + opID + " status is " + response + ".");
  if (status.equalsIgnoreCase("success")) {
    return true;
  } else if (status.equalsIgnoreCase("error") || status.equalsIgnoreCase("failed")) {
    return false;
  } else {
    throw new WalletCallException("Unexpected final operation status response from wallet: " + response.toString());
  }
}

代码示例来源:origin: org.eclipse.leshan/leshan-server-cluster

public static Observation deserialize(byte[] data) {
  JsonObject v = (JsonObject) Json.parse(new String(data));
  EndpointContext endpointContext = EndpointContextSerDes.deserialize(v.get("peer").asObject());
  byte[] req = Hex.decodeHex(v.getString("request", null).toCharArray());
  RawData rawData = RawData.outbound(req, endpointContext, null, false);
  Request request = (Request) parser.parseMessage(rawData);
  request.setDestinationContext(endpointContext);
  JsonValue ctxValue = v.get("context");
  if (ctxValue != null) {
    Map<String, String> context = new HashMap<>();
    JsonObject ctxObject = (JsonObject) ctxValue;
    for (String name : ctxObject.names()) {
      context.put(name, ctxObject.getString(name, null));
    }
    request.setUserContext(context);
  }
  return new Observation(request, endpointContext);
}

代码示例来源:origin: eclipse/leshan

public static Observation deserialize(byte[] data) {
  JsonObject v = (JsonObject) Json.parse(new String(data));
  EndpointContext endpointContext = EndpointContextSerDes.deserialize(v.get("peer").asObject());
  byte[] req = Hex.decodeHex(v.getString("request", null).toCharArray());
  RawData rawData = RawData.outbound(req, endpointContext, null, false);
  Request request = (Request) parser.parseMessage(rawData);
  request.setDestinationContext(endpointContext);
  JsonValue ctxValue = v.get("context");
  if (ctxValue != null) {
    Map<String, String> context = new HashMap<>();
    JsonObject ctxObject = (JsonObject) ctxValue;
    for (String name : ctxObject.names()) {
      context.put(name, ctxObject.getString(name, null));
    }
    request.setUserContext(context);
  }
  return new Observation(request, endpointContext);
}

代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet

public synchronized String getOperationFinalErrorMessage(String opID)
    throws WalletCallException, IOException, InterruptedException {
  JsonArray response = this.executeCommandAndGetJsonArray(
      "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
  JsonObject jsonStatus = response.get(0).asObject();
  JsonObject jsonError = jsonStatus.get("error").asObject();
  return jsonError.getString("message", "ERROR!");
}

代码示例来源:origin: ZencashOfficial/zencash-swing-wallet-ui

public synchronized String getOperationFinalErrorMessage(String opID)
  throws WalletCallException, IOException, InterruptedException
{
  JsonArray response = this.executeCommandAndGetJsonArray(
    "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
  JsonObject jsonStatus = response.get(0).asObject();
  JsonObject jsonError = jsonStatus.get("error").asObject();
  return jsonError.getString("message", "ERROR!");
}

代码示例来源:origin: Fanping/iveely.search

private Packet dropTable(String jsonValue) {
 String dbName = JsonObject.readFrom(jsonValue).getString("dbName", "");
 String tableName = JsonObject.readFrom(jsonValue).getString("tableName", "");
 Warehouse warehouse = LocalStore.getWarehouse(dbName);
 int type = ExchangeCode.DROP_TABLE_FALURE.ordinal();
 String responseInfor = "Falure";
 if (warehouse.dropTable(tableName)) {
  type = ExchangeCode.DROP_TABLE_SUCCESS.ordinal();
  responseInfor = "Success";
 }
 Packet resPacket = new Packet();
 resPacket.setMimeType(0);
 resPacket.setExecuteType(type);
 resPacket.setData(new SimpleString(responseInfor));
 return resPacket;
}

代码示例来源:origin: Fanping/iveely.search

private Packet countTable(String jsonValue) {
 String dbName = JsonObject.readFrom(jsonValue).getString("dbName", "");
 String tableName = JsonObject.readFrom(jsonValue).getString("tableName", "");
 Warehouse warehouse = LocalStore.getWarehouse(dbName);
 int type = ExchangeCode.COUNT_TABLE_FALURE.ordinal();
 String responseInfor = "Falure";
 int count = warehouse.count(tableName);
 if (count > -1) {
  type = ExchangeCode.COUNT_TABLE_SUCCESS.ordinal();
  responseInfor = count + "";
 }
 Packet resPacket = new Packet();
 resPacket.setMimeType(0);
 resPacket.setExecuteType(type);
 resPacket.setData(new SimpleString(responseInfor));
 return resPacket;
}

代码示例来源:origin: dernasherbrezon/r2cloud

@Test
public void testSaveAndLoad() {
  String apiKey = UUID.randomUUID().toString();
  boolean syncSpectogram = true;
  client.saveR2CloudConfiguration(apiKey, syncSpectogram);
  JsonObject config = client.getR2CloudConfiguration();
  assertEquals(apiKey, config.getString("apiKey", null));
  assertTrue(config.getBoolean("syncSpectogram", false));
}

相关文章