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

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

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

JsonObject.getInt介绍

[英]Returns the int 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 will be picked. If this member's value does not represent a JSON number or if it cannot be interpreted as Java int, an exception is thrown.
[中]返回此对象中具有指定名称的成员的int值。如果此对象不包含具有此名称的成员,则返回给定的默认值。如果此对象包含多个具有给定名称的成员,则将拾取最后一个成员。如果此成员的值不表示JSON编号,或者无法将其解释为Javaint,则会引发异常。

代码示例

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

/**
   *  Process an object.
   *  @param object The object.
   *  @param targetcl    If not null, the traverser should make sure that the result object is compatible with the class loader,
   *    e.g. by cloning the object using the class loaded from the target class loader.
   *  @return The processed object.
   */
  public Object process(Object object, Type type, List<ITraverseProcessor> processors, 
    Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context)
  {
    JsonObject obj = (JsonObject)object;
  
    int x = obj.getInt("x", 0);
    int y = obj.getInt("y", 0);
    int w = obj.getInt("w", 0);
    int h = obj.getInt("h", 0);
  
    Rectangle ret = new Rectangle(x, y, w, h);
//        traversed.put(object, ret);
//        ((JsonReadContext)context).addKnownObject(ret);
    
    JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER);
    if(idx!=null)
      ((JsonReadContext)context).addKnownObject(ret, idx.asInt());
    
    return ret;
  }
}

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

/**
   *  Process an object.
   *  @param object The object.
   *  @param targetcl    If not null, the traverser should make sure that the result object is compatible with the class loader,
   *    e.g. by cloning the object using the class loaded from the target class loader.
   *  @return The processed object.
   */
  public Object process(Object object, Type type, List<ITraverseProcessor> processors, 
    Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context)
  {
    JsonObject obj = (JsonObject)object;
    
    int num = obj.getInt(JsonTraverser.REFERENCE_MARKER, 0);

    return ((JsonReadContext)context).getKnownObject(num);
//        return traversed.get(Integer.valueOf(num));
  }
}

代码示例来源:origin: GSLabDev/pepper-box

int brokerPort = jsonObject.getInt(PropsKeys.PORT, -1);

代码示例来源:origin: GSLabDev/pepper-box

int brokerPort = jsonObject.getInt(PropsKeys.PORT, -1);

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

/**
   *  Process an object.
   *  @param object The object.
   *  @param targetcl    If not null, the traverser should make sure that the result object is compatible with the class loader,
   *    e.g. by cloning the object using the class loaded from the target class loader.
   *  @return The processed object.
   */
  public Object process(Object object, Type type, List<ITraverseProcessor> processors, 
    Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context)
  {
    JsonObject obj = (JsonObject)object;
    int rgb = obj.getInt("value", 0);
    Color ret = new Color(rgb);
//        traversed.put(object, ret);
//        ((JsonReadContext)context).addKnownObject(ret);
    
    JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER);
    if(idx!=null)
      ((JsonReadContext)context).addKnownObject(ret, idx.asInt());
    return ret;
  }
}

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

int num = obj.getInt("id", 0);
ret = DEFAULT_LEVELS[num];
int val = obj.getInt("value", 0);

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

/**
   *  Process an object.
   *  @param object The object.
   *  @param targetcl    If not null, the traverser should make sure that the result object is compatible with the class loader,
   *    e.g. by cloning the object using the class loaded from the target class loader.
   *  @return The processed object.
   */
  public Object process(Object object, Type type, List<ITraverseProcessor> processors, 
    Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context)
  {
    JsonObject obj = (JsonObject)object;
    
    long time = obj.getLong("time", 0);
    int nanos = obj.getInt("nanos", 0);
    Timestamp ret = new Timestamp(time);
    ret.setNanos(nanos);
//        traversed.put(object, ret);
//        ((JsonReadContext)context).addKnownObject(ret);
    
    JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER);
    if(idx!=null)
      ((JsonReadContext)context).addKnownObject(ret, idx.asInt());
    
    return ret;
  }
}

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

public synchronized ShieldCoinbaseResponse shieldCoinbase(String from, String to)
    throws WalletCallException, IOException, InterruptedException {
  JsonObject objResponse = this.executeCommandAndGetJsonObject(
      "z_shieldcoinbase", wrapStringParameter(from),
          wrapStringParameter(to));
  ShieldCoinbaseResponse shieldCoinbaseResponse = new ShieldCoinbaseResponse();
  shieldCoinbaseResponse.operationid = objResponse.getString("operationid", null);
  shieldCoinbaseResponse.shieldedUTXOs = objResponse.getInt("shieldedUTXOs", -1);
  if (shieldCoinbaseResponse.shieldedUTXOs == -1) {
    shieldCoinbaseResponse.shieldedUTXOs = objResponse.getInt("shieldingUTXOs", -1);
  }
  shieldCoinbaseResponse.shieldedValue = objResponse.getDouble("shieldedValue", -1);
  if (shieldCoinbaseResponse.shieldedValue == -1) {
    shieldCoinbaseResponse.shieldedValue = objResponse.getDouble("shieldingValue", -1);
  }
  shieldCoinbaseResponse.remainingUTXOs = objResponse.getInt("remainingUTXOs", -1);
  shieldCoinbaseResponse.remainingValue = objResponse.getDouble("remainingValue", -1);
  if (shieldCoinbaseResponse.shieldedValue != -1) {
    return shieldCoinbaseResponse;
  } else {
    throw new WalletCallException("Unexpected z_shieldcoinbase response from wallet: " + objResponse.toString());
  }
}

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

/**
 * Gets Stats from input stream and closes the stream at the end.
 * @param is where data is present. It is closed at the end.
 * @return Stats object.
 * @throws IOException
 */
public static final Stats fromInputStream(final InputStream is) throws IOException {
  final Stats currentStats = new Stats();
  try (final BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
    final JsonValue parse = Json.parse(reader);
    final JsonArray arrayOfStats = parse.asArray();
    for (JsonValue value : arrayOfStats) {
      final JsonObject stat = value.asObject();
      final JsonObject endpoint = stat.get("endpoint").asObject();
      final String method = endpoint.getString("method", "");
      final String path = endpoint.getString("path", "");
      final int errors = stat.getInt("errors", 0);
      final int success = stat.getInt("success", 0);
      final double averagePrimaryDuration = stat.getDouble("averagePrimaryDuration", 0.0);
      final double averageCandidateDuration = stat.getDouble("averageCandidateDuration", 0.0);
      final List<ErrorDetail> errorDetailList = parseErrorDetails(stat);
      currentStats.stats.add(
        new Stat(method, path, errors, success, averagePrimaryDuration, averageCandidateDuration, errorDetailList)
      );
    }
  }
  return currentStats;
}

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

public static LwM2mNode deserialize(JsonObject o) {
  String kind = o.getString("kind", null);
  int id = o.getInt("id", LwM2mObjectInstance.UNDEFINED);

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

/**
   *  Process an object.
   *  @param object The object.
   *  @param targetcl    If not null, the traverser should make sure that the result object is compatible with the class loader,
   *    e.g. by cloning the object using the class loaded from the target class loader.
   *  @return The processed object.
   */
  public Object process(Object object, Type type, List<ITraverseProcessor> processors, 
    Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context)
  {
    Class<?> clazz = SReflect.getClass(type);
    JsonObject obj = (JsonObject)object;
    
    String classname = obj.getString("classname", null);
    String methodname = obj.getString("methodname", null);
    String filename = obj.getString("filename", null);
    int linenumber = obj.getInt("linenumber", 0);

    StackTraceElement ret = new StackTraceElement(classname, methodname, filename, linenumber);
//        traversed.put(object, ret);
//        ((JsonReadContext)context).addKnownObject(ret);
    
    JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER);
    if(idx!=null)
      ((JsonReadContext)context).addKnownObject(ret, idx.asInt());
    
    return ret;
  }
}

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

@Override
  public ObjectModel deserialize(JsonObject o) {
    if (o == null)
      return null;

    if (!o.isObject())
      return null;

    int id = o.getInt("id", -1);
    if (id < 0)
      return null;

    String name = o.getString("name", null);
    String instancetype = o.getString("instancetype", null);
    boolean mandatory = o.getBoolean("mandatory", false);
    String description = o.getString("description", null);
    String version = o.getString("version", ObjectModel.DEFAULT_VERSION);
    List<ResourceModel> resourceSpecs = resourceModelSerDes.deserialize(o.get("resourcedefs").asArray());

    return new ObjectModel(id, name, description, version, "multiple".equals(instancetype), mandatory,
        resourceSpecs);
  }
}

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

@Override
  public ResourceModel deserialize(JsonObject o) {
    if (o == null)
      return null;

    if (!o.isObject())
      return null;

    int id = o.getInt("id", -1);
    if (id < 0)
      return null;

    String name = o.getString("name", null);
    Operations operations = Operations.valueOf(o.getString("operations", null));
    String instancetype = o.getString("instancetype", null);
    boolean mandatory = o.getBoolean("mandatory", false);
    Type type = Type.valueOf(o.getString("type", "").toUpperCase());
    String range = o.getString("range", null);
    String units = o.getString("units", null);
    String description = o.getString("description", null);

    return new ResourceModel(id, name, operations, "multiple".equals(instancetype), mandatory, type, range, units,
        description);
  }
}

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

this.diferenciaConfiguration.candidate = configuration.getString("candidate", "");
this.diferenciaConfiguration.secondary = configuration.getString("secondary", null);
this.diferenciaConfiguration.port = configuration.getInt("port", 0);
this.diferenciaConfiguration.prometheusPort = configuration.getInt("prometheusPort", 0);
this.diferenciaConfiguration.adminPort = configuration.getInt("adminPort", 0);
this.diferenciaConfiguration.serviceName = configuration.getString("serviceName", "");
this.diferenciaConfiguration.storeResults = configuration.getString("storeResults", null);

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

int version          = message.getInt("ver",              -1);
String msg           = message.getString("message",       "");
String threadID      = message.getString("threadid",      "");
int version          = message.getInt("ver",              -1);
String from          = message.getString("from",          "");
String msg           = message.getString("message",       "");

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

public static Registration deserialize(JsonObject jObj) {
  Registration.Builder b = new Registration.Builder(jObj.getString("regId", null), jObj.getString("ep", null),
      IdentitySerDes.deserialize(jObj.get("identity").asObject()),
      new InetSocketAddress(jObj.getString("regAddr", null), jObj.getInt("regPort", 0)));
  b.bindingMode(BindingMode.valueOf(jObj.getString("bnd", null)));
  b.lastUpdate(new Date(jObj.getLong("lastUp", 0)));

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

public static Registration deserialize(JsonObject jObj) {
  Registration.Builder b = new Registration.Builder(jObj.getString("regId", null), jObj.getString("ep", null),
      IdentitySerDes.deserialize(jObj.get("identity").asObject()),
      new InetSocketAddress(jObj.getString("regAddr", null), jObj.getInt("regPort", 0)));
  b.bindingMode(BindingMode.valueOf(jObj.getString("bnd", null)));
  b.lastUpdate(new Date(jObj.getLong("lastUp", 0)));

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

public void copyFromJSONObject(JsonObject obj)
{
  // Wire protocol fields
  this.version       = obj.getInt("ver",              1);
  this.from          = obj.getString("from",          "");
  this.message       = obj.getString("message",       "");
  this.sign          = obj.getString("sign",          "");
  this.threadID      = obj.getString("threadid",      "");	
  this.returnAddress = obj.getString("returnaddress", "");
  
  // Additional fields - may be missing, get default values
  this.transactionID = obj.getString("transactionID", "");
  this.time          = new Date(obj.getLong("time",   0));
  this.direction     = DIRECTION_TYPE.valueOf(
               obj.getString("direction", DIRECTION_TYPE.RECEIVED.toString()));
  this.verification  = VERIFICATION_TYPE.valueOf(
               obj.getString("verification", VERIFICATION_TYPE.UNVERIFIED.toString()));
  
  if (obj.get("isanonymous") != null)
  {
    this.isAnonymous = obj.getBoolean("isanonymous", false);
  } else
  {
    // Determine from content if it is anonymous
    this.isAnonymous = obj.get("threadid") != null; 
  }
}

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

public void copyFromJSONObject(JsonObject obj)
{
  // Wire protocol fields
  this.version       = obj.getInt("ver",              1);
  this.from          = obj.getString("from",          "");
  this.message       = obj.getString("message",       "");
  this.sign          = obj.getString("sign",          "");
  this.threadID      = obj.getString("threadid",      "");
  this.returnAddress = obj.getString("returnaddress", "");
  // Additional fields - may be missing, get default values
  this.transactionID = obj.getString("transactionID", "");
  this.time          = new Date(obj.getLong("time",   0));
  this.direction     = DIRECTION_TYPE.valueOf(
      obj.getString("direction", DIRECTION_TYPE.RECEIVED.toString()));
  this.verification  = VERIFICATION_TYPE.valueOf(
      obj.getString("verification", VERIFICATION_TYPE.UNVERIFIED.toString()));
  if (obj.get("isanonymous") != null)
  {
    this.isAnonymous = obj.getBoolean("isanonymous", false);
  } else
  {
    // Determine from content if it is anonymous
    this.isAnonymous = obj.get("threadid") != null;
  }
}

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

public static ObservationFull fromJson(JsonObject meta) {
  ObservationRequest req = new ObservationRequest();
  req.setId(meta.getString("id", null));
  req.setStartTimeMillis(meta.getLong("start", -1L));
  req.setEndTimeMillis(meta.getLong("end", -1L));
  req.setOutputSampleRate(meta.getInt("sampleRate", -1));
  req.setInputSampleRate(meta.getInt("inputSampleRate", -1));
  req.setSatelliteFrequency(meta.getLong("frequency", -1));
  req.setActualFrequency(meta.getLong("actualFrequency", -1));
  req.setBandwidth(meta.getLong("bandwidth", -1));
  req.setDecoder(meta.getString("decoder", null));
  req.setSatelliteId(meta.getString("satellite", null));
  ObservationResult result = new ObservationResult();
  result.setGain(meta.getString("gain", null));
  result.setChannelA(meta.getString("channelA", null));
  result.setChannelB(meta.getString("channelB", null));
  JsonValue decodedPackets = meta.get("numberOfDecodedPackets");
  if (decodedPackets != null) {
    result.setNumberOfDecodedPackets(decodedPackets.asLong());
  }
  result.setaURL(meta.getString("aURL", null));
  result.setDataURL(meta.getString("data", null));
  result.setSpectogramURL(meta.getString("spectogramURL", null));
  ObservationFull full = new ObservationFull(req);
  full.setResult(result);
  return full;
}

相关文章