com.github.openjson.JSONObject.getInt()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(152)

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

JSONObject.getInt介绍

[英]Returns the value mapped by name if it exists and is an int or can be coerced to an int, or throws otherwise.
[中]返回按名称映射的值(如果该值存在且为int或可以强制为int或抛出其他值)。

代码示例

代码示例来源:origin: triplea-game/triplea

private int getUserId(final CloseableHttpClient client) throws IOException {
 final JSONObject jsonObject = queryUserInfo(client);
 checkUser(jsonObject);
 return jsonObject.getInt("uid");
}

代码示例来源:origin: OrienteerBAP/Orienteer

public void updateDashboardByJson(DashboardPanel<?> dashboard, String data) {
  final Map<String, AbstractWidget<?>> widgetsByMarkupId = new HashMap<String, AbstractWidget<?>>();
  dashboard.visitChildren(AbstractWidget.class, new IVisitor<AbstractWidget<?>, Void>() {
    @Override
    public void component(AbstractWidget<?> widget, IVisit<Void> visit) {
      widgetsByMarkupId.put(widget.getMarkupId(), widget);
      visit.dontGoDeeper();
    }
    
  });
  try {
    JSONArray jsonArray = new JSONArray(data);
    for(int i=0; i<jsonArray.length();i++) {
      JSONObject jsonWidget = jsonArray.getJSONObject(i);
      String markupId = jsonWidget.getString("id");
      AbstractWidget<?> widget = widgetsByMarkupId.get(markupId);
      GridsterWidgetBehavior behaviour = GridsterWidgetBehavior.getBehaviour(widget);
      behaviour.setCol(jsonWidget.getInt("col"));
      behaviour.setRow(jsonWidget.getInt("row"));
      behaviour.setSizeX(jsonWidget.getInt("size_x"));
      behaviour.setSizeY(jsonWidget.getInt("size_y"));
    }
  } catch (JSONException e) {
    throw new WicketRuntimeException("Can't handle dashboard update", e);
  }
}

代码示例来源:origin: inception-project/inception

public MtasUimaParser(MtasConfiguration config)
{
  super(config);
  
  // Perform dependency injection
  AutowireCapableBeanFactory factory = ApplicationContextProvider.getApplicationContext()
      .getAutowireCapableBeanFactory();
  factory.autowireBean(this);
  factory.initializeBean(this, "transientParser");
  
  // Process configuration
  // Read parser argument that contains the projectId
  JSONObject jsonParserConfiguration = new JSONObject(
      config.attributes.get(MtasTokenizerFactory.ARGUMENT_PARSER_ARGS));
  project = projectService.getProject(jsonParserConfiguration.getInt("projectId"));
  
  // Initialize and populate the hash maps for the layers and features
  initLayerAndFeatureCache();
}

代码示例来源:origin: triplea-game/triplea

public static List<DownloadFileDescription> parse(final InputStream is) {
  final JSONArray yamlData = new JSONArray(new Yaml().loadAs(is, List.class));

  final List<DownloadFileDescription> downloads = new ArrayList<>();
  OpenJsonUtils.stream(yamlData).map(JSONObject.class::cast).forEach(yaml -> {
   final String url = yaml.getString(Tags.url.toString());
   final String description = yaml.getString(Tags.description.toString());
   final String mapName = yaml.getString(Tags.mapName.toString());

   final Version version = new Version(yaml.getInt(Tags.version.toString()), 0);
   final DownloadFileDescription.DownloadType downloadType = OpenJsonUtils.optEnum(
     yaml,
     DownloadFileDescription.DownloadType.class,
     Tags.mapType.toString(),
     DownloadFileDescription.DownloadType.MAP);

   final DownloadFileDescription.MapCategory mapCategory = OpenJsonUtils.optEnum(
     yaml,
     DownloadFileDescription.MapCategory.class,
     Tags.mapCategory.toString(),
     DownloadFileDescription.MapCategory.EXPERIMENTAL);

   final String img = yaml.optString(Tags.img.toString());
   final DownloadFileDescription dl =
     new DownloadFileDescription(url, description, mapName, version, downloadType, mapCategory, img);
   downloads.add(dl);
  });
  return downloads;
 }
}

代码示例来源:origin: OrienteerBAP/Orienteer

private static OArchitectOProperty convertOPropertyFromJson(JSONObject jsonObject) {
  String name = !jsonObject.isNull(NAME) ? jsonObject.getString(NAME) : null;
  OType type = !jsonObject.isNull(TYPE) ? OType.valueOf(jsonObject.getString(TYPE)) : null;
  OArchitectOProperty property = null;
  if (!Strings.isNullOrEmpty(name) && type != null) {
    property = new OArchitectOProperty(name, type);
    if (!jsonObject.isNull(SUBCLASS_PROPERTY)) {
      String subClassProperty = jsonObject.getString(SUBCLASS_PROPERTY);
      property.setSubClassProperty(subClassProperty.equals("1") || subClassProperty.equals("true"));
    }
    if (!jsonObject.isNull(LINKED_CLASS_NAME)) {
      property.setLinkedClass(jsonObject.getString(LINKED_CLASS_NAME));
    }
    if (!jsonObject.isNull(ORDER)) {
      property.setOrder(jsonObject.getInt(ORDER));
    }
    if (!jsonObject.isNull(INVERSE_PROPERY_ENABLE)) {
      property.setInversePropertyEnable(jsonObject.getBoolean(INVERSE_PROPERY_ENABLE));
      if (!jsonObject.isNull(INVERSE_PROPERTY)) {
        property.setInverseProperty(convertInverseProperty(jsonObject.getJSONObject(INVERSE_PROPERTY)));
      }
    }
  }
  return property;
}

相关文章