javax.json.JsonObject.getOrDefault()方法的使用及代码示例

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

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

JsonObject.getOrDefault介绍

暂无

代码示例

代码示例来源:origin: jcabi/jcabi-github

/**
 * Is it private?.
 * @return TRUE if it's private
 * @throws IOException If there is any I/O problem
 */
public boolean isPrivate() throws IOException {
  return Boolean.parseBoolean(
    this.json()
      .getOrDefault("private", JsonValue.FALSE)
      .toString().replace("\"", "")
  );
}
@Override

代码示例来源:origin: jcabi/jcabi-github

/**
 * Is it prerelease.
 * @return Returns true if it's prerelease
 * @throws IOException If there is any I/O problem
 */
public boolean prerelease() throws IOException {
  return Boolean.parseBoolean(
    this.json()
      .getOrDefault("prerelease", JsonValue.FALSE)
      .toString().replace("\"", "")
  );
}

代码示例来源:origin: webrtc/KITE

/**
 * Constructs a new TestConf with the given callback url and JsonObject.
 *
 * @param callbackURL a string representation of callback url.
 * @param jsonObject  JsonObject
 */
public Test(String callbackURL, JsonObject jsonObject) {
 this.name = jsonObject.getString("name");
 this.testImpl = jsonObject.getString("testImpl");
 this.description =
   jsonObject.getString("description", "No description was provided fot this test.");
 this.payload = jsonObject.getOrDefault("payload", null);
 // Override the global value with the local value
 this.callbackURL = jsonObject.getString("callback", null);
 if (this.callbackURL == null)
  this.callbackURL = callbackURL;
}

代码示例来源:origin: org.realityforge.replicant/replicant-client

@GwtIncompatible
@Nullable
private ChannelChange[] parseChannelChanges( @Nonnull final JsonObject object )
{
 if ( object.containsKey( "channel_actions" ) )
 {
  final ArrayList<ChannelChange> changes = new ArrayList<>();
  for ( final JsonValue value : object.getJsonArray( "channel_actions" ) )
  {
   final JsonObject change = (JsonObject) value;
   final int cid = change.getInt( "cid" );
   final Integer scid = change.containsKey( "scid" ) ? change.getInt( "scid" ) : null;
   final ChannelChange.Action action =
    ChannelChange.Action.valueOf( change.getString( "action" ).toUpperCase() );
   // TODO: Filters not yet supported properly
   final Object filter = change.getOrDefault( "filter", null );
   changes.add( null == scid ?
          ChannelChange.create( cid, action, filter ) :
          ChannelChange.create( cid, scid, action, filter ) );
  }
  return changes.toArray( new ChannelChange[ 0 ] );
 }
 else
 {
  return null;
 }
}

代码示例来源:origin: webrtc/KITE

/**
 * Constructs a new Browser with the given remote address and JsonObject.
 *
 * @param remoteAddress a string representation of the Selenium hub url
 * @param jsonObject    JsonObject
 */
public Browser(String remoteAddress, JsonObject jsonObject)
  throws KiteInsufficientValueException {
 this.browserName = jsonObject.getString("browserName");
 this.version = jsonObject.getString("version");
 this.platform = jsonObject.getString("platform");
 this.focus = jsonObject.getBoolean("focus", true);
 this.headless = jsonObject.getBoolean("headless", false);
 this.technologyPreview = jsonObject.getBoolean("technologyPreview", false);
 this.remoteAddress = jsonObject.getString("remoteAddress", remoteAddress);
 this.pathToBinary = jsonObject.getString("pathToBinary", "");
 this.fakeMediaFile = jsonObject.getString("fakeMediaFile", null);
 JsonValue jsonValue = jsonObject.getOrDefault("flags", null);
 if (jsonValue != null) {
  JsonArray flagArray = (JsonArray) jsonValue;
  for (int i = 0; i < flagArray.size(); i++){
   this.flags.add(flagArray.getString(i));
  }
 }
 JsonValue mobile = jsonObject.getOrDefault("mobile", null);
 if (mobile != null){
  this.mobile = new Mobile((JsonObject) mobile);
 }
}

相关文章