org.json.JSONArray.forEach()方法的使用及代码示例

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

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

JSONArray.forEach介绍

暂无

代码示例

代码示例来源:origin: loklak/loklak_server

choices.forEach(json -> max.set(Math.max(max.get(), ((JSONObject) json).getDouble(c))));
  return a.put(new JSONObject().put(aggregator_as, max.get()));
  choices.forEach(json -> min.set(Math.min(min.get(), ((JSONObject) json).getDouble(c))));
  return a.put(new JSONObject().put(aggregator_as, min.get()));
  choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c)));
  return a.put(new JSONObject().put(aggregator_as, sum.get()));
  choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c)));
  return a.put(new JSONObject().put(aggregator_as, sum.get() / choices.length()));
if (aggregator.startsWith("PERCENT(") && aggregator.endsWith(")")) {
  final AtomicDouble sum = new AtomicDouble(0.0d); String c = aggregator.substring(8, aggregator.length() - 1);
  choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c)));
  choices.forEach(json -> a.put(new JSONObject()
      .put(aggregator_as, 100.0d * ((JSONObject) json).getDouble(c) / sum.get())
      .put(column_as, ((JSONObject) json).get(column_final))));

代码示例来源:origin: yacy/yacy_grid_mcp

public String toString() {
  StringBuffer sb = new StringBuffer();
  this.array.forEach(entry -> sb.append(entry.toString()).append("\n"));
  return sb.toString();
}

代码示例来源:origin: yacy/yacy_grid_mcp

/**
 * To be able to apply (re-)actions to this thought, the actions on the information can be retrieved.
 * @return the (re-)actions which are applicable to this thought.
 */
public List<SusiAction> getActions() {
  List<SusiAction> actions = new ArrayList<>();
  getActionsJSON().forEach(action -> actions.add(new SusiAction((JSONObject) action)));
  return actions;
}

代码示例来源:origin: yacy/yacy_grid_mcp

public List<Action> getActions() {
  List<Action> actions = new ArrayList<>();
  getActionsJSON().forEach(action -> actions.add(new Action((JSONObject) action)));
  return actions;
}

代码示例来源:origin: yacy/yacy_grid_mcp

@SuppressWarnings("unchecked")
public List<Peer> getMCPServiceList() {
  Set<String> failstubs = new HashSet<>();
  JSONArray ja = null;
  loop: for (Set<String> a: new Set[]{mcpActiveAddresses, mcpPassiveAddresses}) {
    for (String hostprotocolstub: a) {
      try {
        ServiceResponse response = APIServer.getAPI(ServicesService.NAME).serviceImpl(hostprotocolstub, new JSONObject());
        ja = response.getArray();
        break loop;
      } catch (IOException e) {
        failstubs.add(hostprotocolstub);
      }
    }
  }
  removeMCP(failstubs);
  List<Peer> list = new ArrayList<>();
  if (ja == null) return list;
  ja.forEach(j -> list.add(new Peer((JSONObject) j)));
  return list;
}

代码示例来源:origin: DV8FromTheWorld/JDA

content.getJSONArray("ids").forEach(id ->
content.getJSONArray("ids").forEach(id -> msgIds.add((String) id));
getJDA().getEventManager().handle(
    new MessageBulkDeleteEvent(

代码示例来源:origin: petersamokhin/vk-bot-java-sdk

/**
 * We add all of updates from longpoll server
 * to queue
 *
 * @param elements Array of updates
 */
void putAll(JSONArray elements) {
  elements.forEach(item -> updates.add((JSONArray) item));
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public List<JSONObject> getRequestNodes() {
  List<JSONObject> obj = new ArrayList<>();
  this.requests.getJSONArray("nodes").forEach(element -> obj.add((JSONObject) element));
  return obj;
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public List<JSONObject> getResponseNodes(){
  List<JSONObject> obj = new ArrayList<>();
  this.responses.getJSONArray("nodes").forEach(element -> obj.add((JSONObject) element));
  return obj;
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public List<JSONArray> getRequestEdges() {
  List<JSONArray> obj = new ArrayList<>();
  this.requests.getJSONArray("edges").forEach(element -> obj.add((JSONArray) element));
  return obj;
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public List<JSONArray> getResponseEdges(){
  List<JSONArray> obj = new ArrayList<>();
  this.responses.getJSONArray("edges").forEach(element -> obj.add((JSONArray) element));
  return obj;
}

代码示例来源:origin: featurecat/lizzie

/** The threshold list of the blunder winrate */
public Optional<List<Double>> blunderWinrateThresholds() {
 String key = "blunder-winrate-thresholds";
 Optional<JSONArray> array = Optional.ofNullable(config.optJSONArray(key));
 if (!array.isPresent()) {
  array = Optional.ofNullable(uiConfig.optJSONArray(key));
 }
 array.ifPresent(
   m -> {
    blunderWinrateThresholds = Optional.of(new ArrayList<Double>());
    m.forEach(a -> blunderWinrateThresholds.get().add(new Double(a.toString())));
   });
 return blunderWinrateThresholds;
}

代码示例来源:origin: phenotips/phenotips

/**
 * Constructor for initializing from a JSON Object. Supports both 1.3-m5 and older 1.3-xx json formats. 1.3-m5 and
 * newer format: {"id": ENSEMBL_Id [[, "gene": HGNC_Symbol] , ...] } 1.3-old format: {"gene": HGNC_Symbol [, ...] }
 *
 * @param geneJson JSON object that holds gene details info
 */
public PhenoTipsGene(JSONObject geneJson)
{
  this(geneJson.optString(ID), geneJson.optString(SYMBOL_KEY), geneJson.optString(STATUS_KEY), null, geneJson
    .optString(COMMENTS_KEY));
  JSONArray strategyArray = geneJson.optJSONArray(STRATEGY_KEY);
  if (strategyArray != null) {
    List<String> strategies = new LinkedList<>();
    strategyArray.forEach(item -> strategies.add(item.toString()));
    this.setStrategy(strategies);
  }
}

代码示例来源:origin: com.github.appiumtestdistribution/devicemanager

/**
 * Gets all available Runtimes
 */
private List<IOSRuntime> getAllRuntimes() throws IOException, InterruptedException {
  CommandPromptUtil commandPromptUtil = new CommandPromptUtil();
  String runtimesJSONString = commandPromptUtil.runCommandThruProcess("xcrun simctl list -j runtimes");
  JSONArray runtimesJSON = new JSONObject(runtimesJSONString).getJSONArray("runtimes");
  List<IOSRuntime> IOSRuntimes = new ArrayList<>();
  runtimesJSON.forEach(runtime -> {
    IOSRuntimes.add(new IOSRuntime((JSONObject) runtime));
  });
  return IOSRuntimes;
}

代码示例来源:origin: com.github.appiumtestdistribution/devicemanager

/**
 * Gets all available DeviceType
 */
private List<DeviceType> getAllDeviceTypes() throws IOException, InterruptedException {
  CommandPromptUtil commandPromptUtil = new CommandPromptUtil();
  String deviceTypesJSONString = commandPromptUtil.runCommandThruProcess("xcrun simctl list -j devicetypes");
  JSONObject devicesTypesJSON = new JSONObject(deviceTypesJSONString);
  JSONArray devicesTypes = devicesTypesJSON.getJSONArray("devicetypes");
  List<DeviceType> deviceTypes = new ArrayList<>();
  devicesTypes.forEach(deviceType -> {
    String name = ((JSONObject) deviceType).getString("name");
    String identifier = ((JSONObject) deviceType).getString("identifier");
    deviceTypes.add(new DeviceType(name, identifier));
  });
  return deviceTypes;
}

代码示例来源:origin: com.github.appiumtestdistribution/devicemanager

/**
 * Gets all available Simulators
 */
public List<Device> getAllAvailableSimulators() throws IOException, InterruptedException {
  CommandPromptUtil commandPromptUtil = new CommandPromptUtil();
  String simulatorJsonString = commandPromptUtil.runCommandThruProcess("xcrun simctl list -j devices");
  JSONObject simulatorsJson = new JSONObject(simulatorJsonString);
  JSONObject devicesByTypeJson = (JSONObject) simulatorsJson.get("devices");
  Iterator<String> keys = devicesByTypeJson.keys();
  List<Device> deviceList = new ArrayList<>();
  while (keys.hasNext()) {
    String key = keys.next();
    JSONArray devicesJson = (JSONArray) devicesByTypeJson.get(key);
    devicesJson.forEach(deviceJson -> {
      deviceList.add(new Device((JSONObject) deviceJson, key));
    });
  }
  return deviceList;
}

代码示例来源:origin: lamarios/Homedash2

public static MediaContainer fromJson(JSONObject json) {
  MediaContainer container = new MediaContainer();
  try {
    container.size = json.getInt("size");
  } catch (JSONException e) {
    container.size = 0;
  }
  List<Video> videos = new ArrayList<>();
  try {
    JSONArray videoArray = json.getJSONArray("Metadata");
    videoArray.forEach(object -> {
      videos.add(Video.fromJson((JSONObject) object));
    });
  } catch (JSONException e) {
    try {
      //not an array, but a single object
      videos.add(Video.fromJson(json.getJSONObject("Video")));
    } catch (JSONException e2) {
      //doesn't exist
    }
  }
  container.videos = videos;
  return container;
}

代码示例来源:origin: Apicurio/apicurio-studio

issueNodes.forEach(issueNode -> {
  JSONObject issue = (JSONObject) issueNode;
  String closedOn = issue.getString("closed_at");

代码示例来源:origin: Apicurio/apicurio-studio

responseObj.getJSONArray("values").forEach(obj -> {
  JSONObject b = (JSONObject) obj;
  SourceCodeBranch branch = new SourceCodeBranch();

代码示例来源:origin: Apicurio/apicurio-studio

responseObj.getJSONArray("values").forEach(obj -> {
  BitbucketRepository bbr = new BitbucketRepository();
  JSONObject rep = (JSONObject) obj;

相关文章